diff --git a/lib/lib.core.d.ts b/lib/lib.core.d.ts index 145564d7044..c1843f5207e 100644 --- a/lib/lib.core.d.ts +++ b/lib/lib.core.d.ts @@ -18,8 +18,8 @@ and limitations under the License. /// ECMAScript APIs ///////////////////////////// -declare var NaN: number; -declare var Infinity: number; +declare const NaN: number; +declare const Infinity: number; /** * Evaluates JavaScript code and executes it. @@ -129,7 +129,7 @@ interface ObjectConstructor { (value: any): any; /** A reference to the prototype for a class of objects. */ - prototype: Object; + readonly prototype: Object; /** * Returns the prototype of an object. @@ -220,7 +220,7 @@ interface ObjectConstructor { /** * Provides functionality common to all JavaScript objects. */ -declare var Object: ObjectConstructor; +declare const Object: ObjectConstructor; /** * Creates a new function. @@ -249,7 +249,7 @@ interface Function { bind(thisArg: any, ...argArray: any[]): any; prototype: any; - length: number; + readonly length: number; // Non-standard extensions arguments: any; @@ -263,10 +263,10 @@ interface FunctionConstructor { */ new (...args: string[]): Function; (...args: string[]): Function; - prototype: Function; + readonly prototype: Function; } -declare var Function: FunctionConstructor; +declare const Function: FunctionConstructor; interface IArguments { [index: number]: any; @@ -414,7 +414,7 @@ interface String { trim(): string; /** Returns the length of a String object. */ - length: number; + readonly length: number; // IE extensions /** @@ -427,20 +427,20 @@ interface String { /** Returns the primitive value of the specified object. */ valueOf(): string; - [index: number]: string; + readonly [index: number]: string; } interface StringConstructor { new (value?: any): String; (value?: any): string; - prototype: String; + readonly prototype: String; fromCharCode(...codes: number[]): string; } /** * Allows manipulation and formatting of text strings and determination and location of substrings within strings. */ -declare var String: StringConstructor; +declare const String: StringConstructor; interface Boolean { /** Returns the primitive value of the specified object. */ @@ -450,10 +450,10 @@ interface Boolean { interface BooleanConstructor { new (value?: any): Boolean; (value?: any): boolean; - prototype: Boolean; + readonly prototype: Boolean; } -declare var Boolean: BooleanConstructor; +declare const Boolean: BooleanConstructor; interface Number { /** @@ -487,57 +487,57 @@ interface Number { interface NumberConstructor { new (value?: any): Number; (value?: any): number; - prototype: Number; + readonly prototype: Number; /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ - MAX_VALUE: number; + readonly MAX_VALUE: number; /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ - MIN_VALUE: number; + readonly MIN_VALUE: number; /** * A value that is not a number. * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. */ - NaN: number; + readonly NaN: number; /** * A value that is less than the largest negative number that can be represented in JavaScript. * JavaScript displays NEGATIVE_INFINITY values as -infinity. */ - NEGATIVE_INFINITY: number; + readonly NEGATIVE_INFINITY: number; /** * A value greater than the largest number that can be represented in JavaScript. * JavaScript displays POSITIVE_INFINITY values as infinity. */ - POSITIVE_INFINITY: number; + readonly POSITIVE_INFINITY: number; } /** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: NumberConstructor; +declare const Number: NumberConstructor; interface TemplateStringsArray extends Array { - raw: string[]; + readonly raw: string[]; } interface Math { /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ - E: number; + readonly E: number; /** The natural logarithm of 10. */ - LN10: number; + readonly LN10: number; /** The natural logarithm of 2. */ - LN2: number; + readonly LN2: number; /** The base-2 logarithm of e. */ - LOG2E: number; + readonly LOG2E: number; /** The base-10 logarithm of e. */ - LOG10E: number; + readonly LOG10E: number; /** Pi. This is the ratio of the circumference of a circle to its diameter. */ - PI: number; + readonly PI: number; /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ - SQRT1_2: number; + readonly SQRT1_2: number; /** The square root of 2. */ - SQRT2: number; + readonly SQRT2: number; /** * Returns the absolute value of a number (the value without regard to whether it is positive or negative). * For example, the absolute value of -5 is the same as the absolute value of 5. @@ -630,7 +630,7 @@ interface Math { tan(x: number): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ -declare var Math: Math; +declare const Math: Math; /** Enables basic storage and retrieval of dates and times. */ interface Date { @@ -792,7 +792,7 @@ interface DateConstructor { new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; (): string; - prototype: Date; + readonly prototype: Date; /** * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. * @param s A date string @@ -812,7 +812,7 @@ interface DateConstructor { now(): number; } -declare var Date: DateConstructor; +declare const Date: DateConstructor; interface RegExpMatchArray extends Array { index?: number; @@ -838,16 +838,16 @@ interface RegExp { test(string: string): boolean; /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ - source: string; + readonly source: string; /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ - global: boolean; + readonly global: boolean; /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ - ignoreCase: boolean; + readonly ignoreCase: boolean; /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ - multiline: boolean; + readonly multiline: boolean; lastIndex: number; @@ -858,7 +858,7 @@ interface RegExp { interface RegExpConstructor { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; - prototype: RegExp; + readonly prototype: RegExp; // Non-standard extensions $1: string; @@ -873,7 +873,7 @@ interface RegExpConstructor { lastMatch: string; } -declare var RegExp: RegExpConstructor; +declare const RegExp: RegExpConstructor; interface Error { name: string; @@ -883,10 +883,10 @@ interface Error { interface ErrorConstructor { new (message?: string): Error; (message?: string): Error; - prototype: Error; + readonly prototype: Error; } -declare var Error: ErrorConstructor; +declare const Error: ErrorConstructor; interface EvalError extends Error { } @@ -894,10 +894,10 @@ interface EvalError extends Error { interface EvalErrorConstructor { new (message?: string): EvalError; (message?: string): EvalError; - prototype: EvalError; + readonly prototype: EvalError; } -declare var EvalError: EvalErrorConstructor; +declare const EvalError: EvalErrorConstructor; interface RangeError extends Error { } @@ -905,10 +905,10 @@ interface RangeError extends Error { interface RangeErrorConstructor { new (message?: string): RangeError; (message?: string): RangeError; - prototype: RangeError; + readonly prototype: RangeError; } -declare var RangeError: RangeErrorConstructor; +declare const RangeError: RangeErrorConstructor; interface ReferenceError extends Error { } @@ -916,10 +916,10 @@ interface ReferenceError extends Error { interface ReferenceErrorConstructor { new (message?: string): ReferenceError; (message?: string): ReferenceError; - prototype: ReferenceError; + readonly prototype: ReferenceError; } -declare var ReferenceError: ReferenceErrorConstructor; +declare const ReferenceError: ReferenceErrorConstructor; interface SyntaxError extends Error { } @@ -927,10 +927,10 @@ interface SyntaxError extends Error { interface SyntaxErrorConstructor { new (message?: string): SyntaxError; (message?: string): SyntaxError; - prototype: SyntaxError; + readonly prototype: SyntaxError; } -declare var SyntaxError: SyntaxErrorConstructor; +declare const SyntaxError: SyntaxErrorConstructor; interface TypeError extends Error { } @@ -938,10 +938,10 @@ interface TypeError extends Error { interface TypeErrorConstructor { new (message?: string): TypeError; (message?: string): TypeError; - prototype: TypeError; + readonly prototype: TypeError; } -declare var TypeError: TypeErrorConstructor; +declare const TypeError: TypeErrorConstructor; interface URIError extends Error { } @@ -949,10 +949,10 @@ interface URIError extends Error { interface URIErrorConstructor { new (message?: string): URIError; (message?: string): URIError; - prototype: URIError; + readonly prototype: URIError; } -declare var URIError: URIErrorConstructor; +declare const URIError: URIErrorConstructor; interface JSON { /** @@ -997,13 +997,115 @@ interface JSON { /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. */ -declare var JSON: JSON; +declare const JSON: JSON; ///////////////////////////// /// ECMAScript Array API (specially handled by compiler) ///////////////////////////// +interface ReadonlyArray { + /** + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ + readonly length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat>(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * 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 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): T[]; + /** + * 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: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; + /** + * 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: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => 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: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + + readonly [n: number]: T; +} + interface Array { /** * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. @@ -1027,12 +1129,7 @@ interface Array { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; + concat(...items: (T | T[])[]): T[]; /** * 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. @@ -1052,19 +1149,16 @@ interface Array { * @param end The end of the specified portion of the array. */ slice(start?: number, end?: number): T[]; - /** * 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: T, b: T) => number): T[]; - /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. */ splice(start: number): T[]; - /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -1072,62 +1166,53 @@ interface Array { * @param items Elements to insert into the array in place of the deleted elements. */ splice(start: number, deleteCount: number, ...items: T[]): T[]; - /** * Inserts new elements at the start of an array. * @param items Elements to insert at the start of the Array. */ unshift(...items: T[]): number; - /** * 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: T, fromIndex?: number): number; - /** * Returns the index of the last occurrence of a specified value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. */ lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - /** * 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - /** * 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: T, index: number, array: T[]) => void, thisArg?: any): void; - /** * 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: T, index: number, array: T[]) => U, thisArg?: any): U[]; - /** * 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: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -1140,7 +1225,6 @@ interface Array { * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: T[]) => 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. @@ -1165,10 +1249,10 @@ interface ArrayConstructor { (arrayLength: number): T[]; (...items: T[]): T[]; isArray(arg: any): arg is Array; - prototype: Array; + readonly prototype: Array; } -declare var Array: ArrayConstructor; +declare const Array: ArrayConstructor; interface TypedPropertyDescriptor { enumerable?: boolean; @@ -1198,11 +1282,10 @@ interface PromiseLike { } interface ArrayLike { - length: number; - [n: number]: T; + readonly length: number; + readonly [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, @@ -1213,7 +1296,7 @@ interface ArrayBuffer { /** * Read-only. The length of the ArrayBuffer (in bytes). */ - byteLength: number; + readonly byteLength: number; /** * Returns a section of an ArrayBuffer. @@ -1222,11 +1305,11 @@ interface ArrayBuffer { } interface ArrayBufferConstructor { - prototype: ArrayBuffer; + readonly prototype: ArrayBuffer; new (byteLength: number): ArrayBuffer; isView(arg: any): arg is ArrayBufferView; } -declare var ArrayBuffer: ArrayBufferConstructor; +declare const ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** @@ -1246,9 +1329,9 @@ interface ArrayBufferView { } interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; + readonly buffer: ArrayBuffer; + readonly byteLength: number; + readonly 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. @@ -1376,7 +1459,7 @@ interface DataView { interface DataViewConstructor { new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; } -declare var DataView: DataViewConstructor; +declare const DataView: DataViewConstructor; /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested @@ -1386,22 +1469,22 @@ interface Int8Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -1500,7 +1583,7 @@ interface Int8Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -1624,7 +1707,7 @@ interface Int8Array { [index: number]: number; } interface Int8ArrayConstructor { - prototype: Int8Array; + readonly prototype: Int8Array; new (length: number): Int8Array; new (array: ArrayLike): Int8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; @@ -1632,7 +1715,7 @@ interface Int8ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -1649,7 +1732,7 @@ interface Int8ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; +declare const Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the @@ -1659,22 +1742,22 @@ interface Uint8Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -1773,7 +1856,7 @@ interface Uint8Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -1898,7 +1981,7 @@ interface Uint8Array { } interface Uint8ArrayConstructor { - prototype: Uint8Array; + readonly prototype: Uint8Array; new (length: number): Uint8Array; new (array: ArrayLike): Uint8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; @@ -1906,7 +1989,7 @@ interface Uint8ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -1923,7 +2006,7 @@ interface Uint8ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; +declare const Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. @@ -1933,22 +2016,22 @@ interface Uint8ClampedArray { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2047,7 +2130,7 @@ interface Uint8ClampedArray { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2172,7 +2255,7 @@ interface Uint8ClampedArray { } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; + readonly prototype: Uint8ClampedArray; new (length: number): Uint8ClampedArray; new (array: ArrayLike): Uint8ClampedArray; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; @@ -2180,7 +2263,7 @@ interface Uint8ClampedArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2196,7 +2279,7 @@ interface Uint8ClampedArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; +declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the @@ -2206,22 +2289,22 @@ interface Int16Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2320,7 +2403,7 @@ interface Int16Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2445,7 +2528,7 @@ interface Int16Array { } interface Int16ArrayConstructor { - prototype: Int16Array; + readonly prototype: Int16Array; new (length: number): Int16Array; new (array: ArrayLike): Int16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; @@ -2453,7 +2536,7 @@ interface Int16ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2470,7 +2553,7 @@ interface Int16ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; +declare const Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the @@ -2480,22 +2563,22 @@ interface Uint16Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2594,7 +2677,7 @@ interface Uint16Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2719,7 +2802,7 @@ interface Uint16Array { } interface Uint16ArrayConstructor { - prototype: Uint16Array; + readonly prototype: Uint16Array; new (length: number): Uint16Array; new (array: ArrayLike): Uint16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; @@ -2727,7 +2810,7 @@ interface Uint16ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2744,7 +2827,7 @@ interface Uint16ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; +declare const 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. @@ -2753,22 +2836,22 @@ interface Int32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2867,7 +2950,7 @@ interface Int32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2992,7 +3075,7 @@ interface Int32Array { } interface Int32ArrayConstructor { - prototype: Int32Array; + readonly prototype: Int32Array; new (length: number): Int32Array; new (array: ArrayLike): Int32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; @@ -3000,7 +3083,7 @@ interface Int32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3016,7 +3099,7 @@ interface Int32ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; +declare const Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the @@ -3026,22 +3109,22 @@ interface Uint32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3140,7 +3223,7 @@ interface Uint32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3265,7 +3348,7 @@ interface Uint32Array { } interface Uint32ArrayConstructor { - prototype: Uint32Array; + readonly prototype: Uint32Array; new (length: number): Uint32Array; new (array: ArrayLike): Uint32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; @@ -3273,7 +3356,7 @@ interface Uint32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3289,7 +3372,7 @@ interface Uint32ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; +declare const Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number @@ -3299,22 +3382,22 @@ interface Float32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3413,7 +3496,7 @@ interface Float32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3538,7 +3621,7 @@ interface Float32Array { } interface Float32ArrayConstructor { - prototype: Float32Array; + readonly prototype: Float32Array; new (length: number): Float32Array; new (array: ArrayLike): Float32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; @@ -3546,7 +3629,7 @@ interface Float32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3563,7 +3646,7 @@ interface Float32ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; +declare const Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested @@ -3573,22 +3656,22 @@ interface Float64Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3687,7 +3770,7 @@ interface Float64Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3812,7 +3895,7 @@ interface Float64Array { } interface Float64ArrayConstructor { - prototype: Float64Array; + readonly prototype: Float64Array; new (length: number): Float64Array; new (array: ArrayLike): Float64Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; @@ -3820,7 +3903,7 @@ interface Float64ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3836,4 +3919,4 @@ interface Float64ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; +declare const Float64Array: Float64ArrayConstructor; diff --git a/lib/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts index 753c3bbf65f..4ccdd73c614 100644 --- a/lib/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -18,8 +18,8 @@ and limitations under the License. /// ECMAScript APIs ///////////////////////////// -declare var NaN: number; -declare var Infinity: number; +declare const NaN: number; +declare const Infinity: number; /** * Evaluates JavaScript code and executes it. @@ -129,7 +129,7 @@ interface ObjectConstructor { (value: any): any; /** A reference to the prototype for a class of objects. */ - prototype: Object; + readonly prototype: Object; /** * Returns the prototype of an object. @@ -220,7 +220,7 @@ interface ObjectConstructor { /** * Provides functionality common to all JavaScript objects. */ -declare var Object: ObjectConstructor; +declare const Object: ObjectConstructor; /** * Creates a new function. @@ -249,7 +249,7 @@ interface Function { bind(thisArg: any, ...argArray: any[]): any; prototype: any; - length: number; + readonly length: number; // Non-standard extensions arguments: any; @@ -263,10 +263,10 @@ interface FunctionConstructor { */ new (...args: string[]): Function; (...args: string[]): Function; - prototype: Function; + readonly prototype: Function; } -declare var Function: FunctionConstructor; +declare const Function: FunctionConstructor; interface IArguments { [index: number]: any; @@ -414,7 +414,7 @@ interface String { trim(): string; /** Returns the length of a String object. */ - length: number; + readonly length: number; // IE extensions /** @@ -427,20 +427,20 @@ interface String { /** Returns the primitive value of the specified object. */ valueOf(): string; - [index: number]: string; + readonly [index: number]: string; } interface StringConstructor { new (value?: any): String; (value?: any): string; - prototype: String; + readonly prototype: String; fromCharCode(...codes: number[]): string; } /** * Allows manipulation and formatting of text strings and determination and location of substrings within strings. */ -declare var String: StringConstructor; +declare const String: StringConstructor; interface Boolean { /** Returns the primitive value of the specified object. */ @@ -450,10 +450,10 @@ interface Boolean { interface BooleanConstructor { new (value?: any): Boolean; (value?: any): boolean; - prototype: Boolean; + readonly prototype: Boolean; } -declare var Boolean: BooleanConstructor; +declare const Boolean: BooleanConstructor; interface Number { /** @@ -487,57 +487,57 @@ interface Number { interface NumberConstructor { new (value?: any): Number; (value?: any): number; - prototype: Number; + readonly prototype: Number; /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ - MAX_VALUE: number; + readonly MAX_VALUE: number; /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ - MIN_VALUE: number; + readonly MIN_VALUE: number; /** * A value that is not a number. * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. */ - NaN: number; + readonly NaN: number; /** * A value that is less than the largest negative number that can be represented in JavaScript. * JavaScript displays NEGATIVE_INFINITY values as -infinity. */ - NEGATIVE_INFINITY: number; + readonly NEGATIVE_INFINITY: number; /** * A value greater than the largest number that can be represented in JavaScript. * JavaScript displays POSITIVE_INFINITY values as infinity. */ - POSITIVE_INFINITY: number; + readonly POSITIVE_INFINITY: number; } /** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: NumberConstructor; +declare const Number: NumberConstructor; interface TemplateStringsArray extends Array { - raw: string[]; + readonly raw: string[]; } interface Math { /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ - E: number; + readonly E: number; /** The natural logarithm of 10. */ - LN10: number; + readonly LN10: number; /** The natural logarithm of 2. */ - LN2: number; + readonly LN2: number; /** The base-2 logarithm of e. */ - LOG2E: number; + readonly LOG2E: number; /** The base-10 logarithm of e. */ - LOG10E: number; + readonly LOG10E: number; /** Pi. This is the ratio of the circumference of a circle to its diameter. */ - PI: number; + readonly PI: number; /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ - SQRT1_2: number; + readonly SQRT1_2: number; /** The square root of 2. */ - SQRT2: number; + readonly SQRT2: number; /** * Returns the absolute value of a number (the value without regard to whether it is positive or negative). * For example, the absolute value of -5 is the same as the absolute value of 5. @@ -630,7 +630,7 @@ interface Math { tan(x: number): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ -declare var Math: Math; +declare const Math: Math; /** Enables basic storage and retrieval of dates and times. */ interface Date { @@ -792,7 +792,7 @@ interface DateConstructor { new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; (): string; - prototype: Date; + readonly prototype: Date; /** * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. * @param s A date string @@ -812,7 +812,7 @@ interface DateConstructor { now(): number; } -declare var Date: DateConstructor; +declare const Date: DateConstructor; interface RegExpMatchArray extends Array { index?: number; @@ -838,16 +838,16 @@ interface RegExp { test(string: string): boolean; /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ - source: string; + readonly source: string; /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ - global: boolean; + readonly global: boolean; /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ - ignoreCase: boolean; + readonly ignoreCase: boolean; /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ - multiline: boolean; + readonly multiline: boolean; lastIndex: number; @@ -858,7 +858,7 @@ interface RegExp { interface RegExpConstructor { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; - prototype: RegExp; + readonly prototype: RegExp; // Non-standard extensions $1: string; @@ -873,7 +873,7 @@ interface RegExpConstructor { lastMatch: string; } -declare var RegExp: RegExpConstructor; +declare const RegExp: RegExpConstructor; interface Error { name: string; @@ -883,10 +883,10 @@ interface Error { interface ErrorConstructor { new (message?: string): Error; (message?: string): Error; - prototype: Error; + readonly prototype: Error; } -declare var Error: ErrorConstructor; +declare const Error: ErrorConstructor; interface EvalError extends Error { } @@ -894,10 +894,10 @@ interface EvalError extends Error { interface EvalErrorConstructor { new (message?: string): EvalError; (message?: string): EvalError; - prototype: EvalError; + readonly prototype: EvalError; } -declare var EvalError: EvalErrorConstructor; +declare const EvalError: EvalErrorConstructor; interface RangeError extends Error { } @@ -905,10 +905,10 @@ interface RangeError extends Error { interface RangeErrorConstructor { new (message?: string): RangeError; (message?: string): RangeError; - prototype: RangeError; + readonly prototype: RangeError; } -declare var RangeError: RangeErrorConstructor; +declare const RangeError: RangeErrorConstructor; interface ReferenceError extends Error { } @@ -916,10 +916,10 @@ interface ReferenceError extends Error { interface ReferenceErrorConstructor { new (message?: string): ReferenceError; (message?: string): ReferenceError; - prototype: ReferenceError; + readonly prototype: ReferenceError; } -declare var ReferenceError: ReferenceErrorConstructor; +declare const ReferenceError: ReferenceErrorConstructor; interface SyntaxError extends Error { } @@ -927,10 +927,10 @@ interface SyntaxError extends Error { interface SyntaxErrorConstructor { new (message?: string): SyntaxError; (message?: string): SyntaxError; - prototype: SyntaxError; + readonly prototype: SyntaxError; } -declare var SyntaxError: SyntaxErrorConstructor; +declare const SyntaxError: SyntaxErrorConstructor; interface TypeError extends Error { } @@ -938,10 +938,10 @@ interface TypeError extends Error { interface TypeErrorConstructor { new (message?: string): TypeError; (message?: string): TypeError; - prototype: TypeError; + readonly prototype: TypeError; } -declare var TypeError: TypeErrorConstructor; +declare const TypeError: TypeErrorConstructor; interface URIError extends Error { } @@ -949,10 +949,10 @@ interface URIError extends Error { interface URIErrorConstructor { new (message?: string): URIError; (message?: string): URIError; - prototype: URIError; + readonly prototype: URIError; } -declare var URIError: URIErrorConstructor; +declare const URIError: URIErrorConstructor; interface JSON { /** @@ -997,13 +997,115 @@ interface JSON { /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. */ -declare var JSON: JSON; +declare const JSON: JSON; ///////////////////////////// /// ECMAScript Array API (specially handled by compiler) ///////////////////////////// +interface ReadonlyArray { + /** + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ + readonly length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat>(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * 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 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): T[]; + /** + * 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: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; + /** + * 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: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => 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: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + + readonly [n: number]: T; +} + interface Array { /** * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. @@ -1027,12 +1129,7 @@ interface Array { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; + concat(...items: (T | T[])[]): T[]; /** * 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. @@ -1052,19 +1149,16 @@ interface Array { * @param end The end of the specified portion of the array. */ slice(start?: number, end?: number): T[]; - /** * 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: T, b: T) => number): T[]; - /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. */ splice(start: number): T[]; - /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -1072,62 +1166,53 @@ interface Array { * @param items Elements to insert into the array in place of the deleted elements. */ splice(start: number, deleteCount: number, ...items: T[]): T[]; - /** * Inserts new elements at the start of an array. * @param items Elements to insert at the start of the Array. */ unshift(...items: T[]): number; - /** * 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: T, fromIndex?: number): number; - /** * Returns the index of the last occurrence of a specified value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. */ lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - /** * 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - /** * 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: T, index: number, array: T[]) => void, thisArg?: any): void; - /** * 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: T, index: number, array: T[]) => U, thisArg?: any): U[]; - /** * 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: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -1140,7 +1225,6 @@ interface Array { * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: T[]) => 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. @@ -1165,10 +1249,10 @@ interface ArrayConstructor { (arrayLength: number): T[]; (...items: T[]): T[]; isArray(arg: any): arg is Array; - prototype: Array; + readonly prototype: Array; } -declare var Array: ArrayConstructor; +declare const Array: ArrayConstructor; interface TypedPropertyDescriptor { enumerable?: boolean; @@ -1198,11 +1282,10 @@ interface PromiseLike { } interface ArrayLike { - length: number; - [n: number]: T; + readonly length: number; + readonly [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, @@ -1213,7 +1296,7 @@ interface ArrayBuffer { /** * Read-only. The length of the ArrayBuffer (in bytes). */ - byteLength: number; + readonly byteLength: number; /** * Returns a section of an ArrayBuffer. @@ -1222,11 +1305,11 @@ interface ArrayBuffer { } interface ArrayBufferConstructor { - prototype: ArrayBuffer; + readonly prototype: ArrayBuffer; new (byteLength: number): ArrayBuffer; isView(arg: any): arg is ArrayBufferView; } -declare var ArrayBuffer: ArrayBufferConstructor; +declare const ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** @@ -1246,9 +1329,9 @@ interface ArrayBufferView { } interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; + readonly buffer: ArrayBuffer; + readonly byteLength: number; + readonly 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. @@ -1376,7 +1459,7 @@ interface DataView { interface DataViewConstructor { new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; } -declare var DataView: DataViewConstructor; +declare const DataView: DataViewConstructor; /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested @@ -1386,22 +1469,22 @@ interface Int8Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -1500,7 +1583,7 @@ interface Int8Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -1624,7 +1707,7 @@ interface Int8Array { [index: number]: number; } interface Int8ArrayConstructor { - prototype: Int8Array; + readonly prototype: Int8Array; new (length: number): Int8Array; new (array: ArrayLike): Int8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; @@ -1632,7 +1715,7 @@ interface Int8ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -1649,7 +1732,7 @@ interface Int8ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; +declare const Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the @@ -1659,22 +1742,22 @@ interface Uint8Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -1773,7 +1856,7 @@ interface Uint8Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -1898,7 +1981,7 @@ interface Uint8Array { } interface Uint8ArrayConstructor { - prototype: Uint8Array; + readonly prototype: Uint8Array; new (length: number): Uint8Array; new (array: ArrayLike): Uint8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; @@ -1906,7 +1989,7 @@ interface Uint8ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -1923,7 +2006,7 @@ interface Uint8ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; +declare const Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. @@ -1933,22 +2016,22 @@ interface Uint8ClampedArray { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2047,7 +2130,7 @@ interface Uint8ClampedArray { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2172,7 +2255,7 @@ interface Uint8ClampedArray { } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; + readonly prototype: Uint8ClampedArray; new (length: number): Uint8ClampedArray; new (array: ArrayLike): Uint8ClampedArray; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; @@ -2180,7 +2263,7 @@ interface Uint8ClampedArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2196,7 +2279,7 @@ interface Uint8ClampedArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; +declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the @@ -2206,22 +2289,22 @@ interface Int16Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2320,7 +2403,7 @@ interface Int16Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2445,7 +2528,7 @@ interface Int16Array { } interface Int16ArrayConstructor { - prototype: Int16Array; + readonly prototype: Int16Array; new (length: number): Int16Array; new (array: ArrayLike): Int16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; @@ -2453,7 +2536,7 @@ interface Int16ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2470,7 +2553,7 @@ interface Int16ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; +declare const Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the @@ -2480,22 +2563,22 @@ interface Uint16Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2594,7 +2677,7 @@ interface Uint16Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2719,7 +2802,7 @@ interface Uint16Array { } interface Uint16ArrayConstructor { - prototype: Uint16Array; + readonly prototype: Uint16Array; new (length: number): Uint16Array; new (array: ArrayLike): Uint16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; @@ -2727,7 +2810,7 @@ interface Uint16ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2744,7 +2827,7 @@ interface Uint16ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; +declare const 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. @@ -2753,22 +2836,22 @@ interface Int32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2867,7 +2950,7 @@ interface Int32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2992,7 +3075,7 @@ interface Int32Array { } interface Int32ArrayConstructor { - prototype: Int32Array; + readonly prototype: Int32Array; new (length: number): Int32Array; new (array: ArrayLike): Int32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; @@ -3000,7 +3083,7 @@ interface Int32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3016,7 +3099,7 @@ interface Int32ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; +declare const Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the @@ -3026,22 +3109,22 @@ interface Uint32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3140,7 +3223,7 @@ interface Uint32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3265,7 +3348,7 @@ interface Uint32Array { } interface Uint32ArrayConstructor { - prototype: Uint32Array; + readonly prototype: Uint32Array; new (length: number): Uint32Array; new (array: ArrayLike): Uint32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; @@ -3273,7 +3356,7 @@ interface Uint32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3289,7 +3372,7 @@ interface Uint32ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; +declare const Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number @@ -3299,22 +3382,22 @@ interface Float32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3413,7 +3496,7 @@ interface Float32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3538,7 +3621,7 @@ interface Float32Array { } interface Float32ArrayConstructor { - prototype: Float32Array; + readonly prototype: Float32Array; new (length: number): Float32Array; new (array: ArrayLike): Float32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; @@ -3546,7 +3629,7 @@ interface Float32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3563,7 +3646,7 @@ interface Float32ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; +declare const Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested @@ -3573,22 +3656,22 @@ interface Float64Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3687,7 +3770,7 @@ interface Float64Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3812,7 +3895,7 @@ interface Float64Array { } interface Float64ArrayConstructor { - prototype: Float64Array; + readonly prototype: Float64Array; new (length: number): Float64Array; new (array: ArrayLike): Float64Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; @@ -3820,7 +3903,7 @@ interface Float64ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3836,7 +3919,7 @@ interface Float64ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; +declare const Float64Array: Float64ArrayConstructor; declare type PropertyKey = string | number | symbol; interface Symbol { @@ -3846,14 +3929,14 @@ interface Symbol { /** Returns the primitive value of the specified object. */ valueOf(): Object; - [Symbol.toStringTag]: "Symbol"; + readonly [Symbol.toStringTag]: "Symbol"; } interface SymbolConstructor { /** * A reference to the prototype. */ - prototype: Symbol; + readonly prototype: Symbol; /** * Returns a new unique Symbol value. @@ -3881,67 +3964,67 @@ interface SymbolConstructor { * A method that determines if a constructor object recognizes an object as one of the * constructor’s instances. Called by the semantics of the instanceof operator. */ - hasInstance: symbol; + readonly hasInstance: symbol; /** * A Boolean value that if true indicates that an object should flatten to its array elements * by Array.prototype.concat. */ - isConcatSpreadable: symbol; + readonly isConcatSpreadable: symbol; /** * A method that returns the default iterator for an object. Called by the semantics of the * for-of statement. */ - iterator: symbol; + readonly iterator: symbol; /** * A regular expression method that matches the regular expression against a string. Called * by the String.prototype.match method. */ - match: symbol; + readonly match: symbol; /** * A regular expression method that replaces matched substrings of a string. Called by the * String.prototype.replace method. */ - replace: symbol; + readonly replace: symbol; /** * A regular expression method that returns the index within a string that matches the * regular expression. Called by the String.prototype.search method. */ - search: symbol; + readonly search: symbol; /** * A function valued property that is the constructor function that is used to create * derived objects. */ - species: symbol; + readonly species: symbol; /** * A regular expression method that splits a string at the indices that match the regular * expression. Called by the String.prototype.split method. */ - split: symbol; + readonly split: symbol; /** * A method that converts an object to a corresponding primitive value. * Called by the ToPrimitive abstract operation. */ - toPrimitive: symbol; + readonly toPrimitive: symbol; /** * A String value that is used in the creation of the default string description of an object. * Called by the built-in method Object.prototype.toString. */ - toStringTag: symbol; + readonly toStringTag: symbol; /** * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ - unscopables: symbol; + readonly unscopables: symbol; } declare var Symbol: SymbolConstructor; @@ -4039,7 +4122,7 @@ interface Function { /** * Returns the name of the function. Function names are read-only and can not be changed. */ - name: string; + readonly name: string; /** * Determines whether the given value inherits from this function if this function was used @@ -4057,7 +4140,7 @@ interface NumberConstructor { * that is representable as a Number value, which is approximately: * 2.2204460492503130808472633361816 x 10‍−‍16. */ - EPSILON: number; + readonly EPSILON: number; /** * Returns true if passed value is finite. @@ -4092,14 +4175,14 @@ interface NumberConstructor { * a Number value. * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. */ - MAX_SAFE_INTEGER: number; + readonly MAX_SAFE_INTEGER: number; /** * The value of the smallest integer n such that n and n − 1 are both exactly representable as * a Number value. * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). */ - MIN_SAFE_INTEGER: number; + readonly MIN_SAFE_INTEGER: number; /** * Converts a string to a floating-point number. @@ -4404,7 +4487,7 @@ interface IterableIterator extends Iterator { } interface GeneratorFunction extends Function { - [Symbol.toStringTag]: "GeneratorFunction"; + readonly [Symbol.toStringTag]: "GeneratorFunction"; } interface GeneratorFunctionConstructor { @@ -4414,7 +4497,7 @@ interface GeneratorFunctionConstructor { */ new (...args: string[]): GeneratorFunction; (...args: string[]): GeneratorFunction; - prototype: GeneratorFunction; + readonly prototype: GeneratorFunction; } declare var GeneratorFunction: GeneratorFunctionConstructor; @@ -4529,7 +4612,7 @@ interface Math { */ cbrt(x: number): number; - [Symbol.toStringTag]: "Math"; + readonly [Symbol.toStringTag]: "Math"; } interface Date { @@ -4615,19 +4698,19 @@ interface RegExp { * * If no flags are set, the value is the empty string. */ - flags: string; + readonly flags: string; /** * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular * expression. Default is false. Read-only. */ - sticky: boolean; + readonly sticky: boolean; /** * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular * expression. Default is false. Read-only. */ - unicode: boolean; + readonly unicode: boolean; } interface RegExpConstructor { @@ -4643,17 +4726,17 @@ interface Map { has(key: K): boolean; keys(): IterableIterator; set(key: K, value?: V): Map; - size: number; + readonly size: number; values(): IterableIterator; [Symbol.iterator]():IterableIterator<[K,V]>; - [Symbol.toStringTag]: "Map"; + readonly [Symbol.toStringTag]: "Map"; } interface MapConstructor { new (): Map; new (): Map; new (iterable: Iterable<[K, V]>): Map; - prototype: Map; + readonly prototype: Map; } declare var Map: MapConstructor; @@ -4663,14 +4746,14 @@ interface WeakMap { get(key: K): V; has(key: K): boolean; set(key: K, value?: V): WeakMap; - [Symbol.toStringTag]: "WeakMap"; + readonly [Symbol.toStringTag]: "WeakMap"; } interface WeakMapConstructor { new (): WeakMap; new (): WeakMap; new (iterable: Iterable<[K, V]>): WeakMap; - prototype: WeakMap; + readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -4682,17 +4765,17 @@ interface Set { forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; has(value: T): boolean; keys(): IterableIterator; - size: number; + readonly size: number; values(): IterableIterator; [Symbol.iterator]():IterableIterator; - [Symbol.toStringTag]: "Set"; + readonly [Symbol.toStringTag]: "Set"; } interface SetConstructor { new (): Set; new (): Set; new (iterable: Iterable): Set; - prototype: Set; + readonly prototype: Set; } declare var Set: SetConstructor; @@ -4701,19 +4784,19 @@ interface WeakSet { clear(): void; delete(value: T): boolean; has(value: T): boolean; - [Symbol.toStringTag]: "WeakSet"; + readonly [Symbol.toStringTag]: "WeakSet"; } interface WeakSetConstructor { new (): WeakSet; new (): WeakSet; new (iterable: Iterable): WeakSet; - prototype: WeakSet; + readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; interface JSON { - [Symbol.toStringTag]: "JSON"; + readonly [Symbol.toStringTag]: "JSON"; } /** @@ -4723,11 +4806,11 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - [Symbol.toStringTag]: "ArrayBuffer"; + readonly [Symbol.toStringTag]: "ArrayBuffer"; } interface DataView { - [Symbol.toStringTag]: "DataView"; + readonly [Symbol.toStringTag]: "DataView"; } /** @@ -4748,7 +4831,7 @@ interface Int8Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Int8Array"; + readonly [Symbol.toStringTag]: "Int8Array"; } interface Int8ArrayConstructor { @@ -4781,7 +4864,7 @@ interface Uint8Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "UInt8Array"; + readonly [Symbol.toStringTag]: "UInt8Array"; } interface Uint8ArrayConstructor { @@ -4817,7 +4900,7 @@ interface Uint8ClampedArray { values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Uint8ClampedArray"; + readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } interface Uint8ClampedArrayConstructor { @@ -4855,7 +4938,7 @@ interface Int16Array { [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Int16Array"; + readonly [Symbol.toStringTag]: "Int16Array"; } interface Int16ArrayConstructor { @@ -4888,7 +4971,7 @@ interface Uint16Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Uint16Array"; + readonly [Symbol.toStringTag]: "Uint16Array"; } interface Uint16ArrayConstructor { @@ -4921,7 +5004,7 @@ interface Int32Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Int32Array"; + readonly [Symbol.toStringTag]: "Int32Array"; } interface Int32ArrayConstructor { @@ -4954,7 +5037,7 @@ interface Uint32Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Uint32Array"; + readonly [Symbol.toStringTag]: "Uint32Array"; } interface Uint32ArrayConstructor { @@ -4987,7 +5070,7 @@ interface Float32Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Float32Array"; + readonly [Symbol.toStringTag]: "Float32Array"; } interface Float32ArrayConstructor { @@ -5020,7 +5103,7 @@ interface Float64Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Float64Array"; + readonly [Symbol.toStringTag]: "Float64Array"; } interface Float64ArrayConstructor { @@ -5097,14 +5180,14 @@ interface Promise { catch(onrejected?: (reason: any) => T | PromiseLike): Promise; catch(onrejected?: (reason: any) => void): Promise; - [Symbol.toStringTag]: "Promise"; + readonly [Symbol.toStringTag]: "Promise"; } interface PromiseConstructor { /** * A reference to the prototype. */ - prototype: Promise; + readonly prototype: Promise; /** * Creates a new Promise. @@ -5166,7 +5249,7 @@ interface PromiseConstructor { */ resolve(): Promise; - [Symbol.species]: Function; + readonly [Symbol.species]: Function; } declare var Promise: PromiseConstructor; diff --git a/lib/lib.core.es7.d.ts b/lib/lib.core.es7.d.ts new file mode 100644 index 00000000000..b5552f62929 --- /dev/null +++ b/lib/lib.core.es7.d.ts @@ -0,0 +1,5344 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare const NaN: number; +declare const Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +interface Object { + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; + + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +interface ObjectConstructor { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + readonly prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: T): T; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: T): T; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: T): T; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare const Object: ObjectConstructor; + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + readonly length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +interface FunctionConstructor { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + readonly prototype: Function; +} + +declare const Function: FunctionConstructor; + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): RegExpMatchArray; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): RegExpMatchArray; + + /** + * Replaces text in a string, using a regular expression or search string. + * @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 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 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 replacer A function that returns the replacement text. + */ + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + readonly length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): string; + + readonly [index: number]: string; +} + +interface StringConstructor { + new (value?: any): String; + (value?: any): string; + readonly prototype: String; + fromCharCode(...codes: number[]): string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare const String: StringConstructor; + +interface Boolean { + /** Returns the primitive value of the specified object. */ + valueOf(): boolean; +} + +interface BooleanConstructor { + new (value?: any): Boolean; + (value?: any): boolean; + readonly prototype: Boolean; +} + +declare const Boolean: BooleanConstructor; + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): number; +} + +interface NumberConstructor { + new (value?: any): Number; + (value?: any): number; + readonly prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + readonly MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + readonly MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + readonly NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + readonly NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + readonly POSITIVE_INFINITY: number; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare const Number: NumberConstructor; + +interface TemplateStringsArray extends Array { + readonly raw: string[]; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + readonly E: number; + /** The natural logarithm of 10. */ + readonly LN10: number; + /** The natural logarithm of 2. */ + readonly LN2: number; + /** The base-2 logarithm of e. */ + readonly LOG2E: number; + /** The base-10 logarithm of e. */ + readonly LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + readonly PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + readonly SQRT1_2: number; + /** The square root of 2. */ + readonly SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point. + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare const Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; + /** Returns a date as a string value in ISO format. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +interface DateConstructor { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + readonly prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +declare const Date: DateConstructor; + +interface RegExpMatchArray extends Array { + index?: number; + input?: string; +} + +interface RegExpExecArray extends Array { + index: number; + input: string; +} + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; + + /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ + readonly source: string; + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + readonly global: boolean; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + readonly ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + readonly multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} + +interface RegExpConstructor { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + readonly prototype: RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +declare const RegExp: RegExpConstructor; + +interface Error { + name: string; + message: string; +} + +interface ErrorConstructor { + new (message?: string): Error; + (message?: string): Error; + readonly prototype: Error; +} + +declare const Error: ErrorConstructor; + +interface EvalError extends Error { +} + +interface EvalErrorConstructor { + new (message?: string): EvalError; + (message?: string): EvalError; + readonly prototype: EvalError; +} + +declare const EvalError: EvalErrorConstructor; + +interface RangeError extends Error { +} + +interface RangeErrorConstructor { + new (message?: string): RangeError; + (message?: string): RangeError; + readonly prototype: RangeError; +} + +declare const RangeError: RangeErrorConstructor; + +interface ReferenceError extends Error { +} + +interface ReferenceErrorConstructor { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + readonly prototype: ReferenceError; +} + +declare const ReferenceError: ReferenceErrorConstructor; + +interface SyntaxError extends Error { +} + +interface SyntaxErrorConstructor { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + readonly prototype: SyntaxError; +} + +declare const SyntaxError: SyntaxErrorConstructor; + +interface TypeError extends Error { +} + +interface TypeErrorConstructor { + new (message?: string): TypeError; + (message?: string): TypeError; + readonly prototype: TypeError; +} + +declare const TypeError: TypeErrorConstructor; + +interface URIError extends Error { +} + +interface URIErrorConstructor { + new (message?: string): URIError; + (message?: string): URIError; + readonly prototype: URIError; +} + +declare const URIError: URIErrorConstructor; + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): 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 A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): 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. + */ + stringify(value: any, replacer: any[]): 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 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: 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: string | number): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare const JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface ReadonlyArray { + /** + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ + readonly length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat>(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * 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 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): T[]; + /** + * 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: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; + /** + * 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: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => 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: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + + readonly [n: number]: T; +} + +interface Array { + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: (T | T[])[]): T[]; + /** + * 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; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * 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): T[]; + /** + * 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: T, b: T) => number): T[]; + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + /** + * 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: T, fromIndex?: number): number; + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: T[]) => void, thisArg?: any): void; + /** + * 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: T, index: number, array: T[]) => U, thisArg?: any): U[]; + /** + * 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: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: T[]) => 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: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + [n: number]: T; +} + +interface ArrayConstructor { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): arg is Array; + readonly prototype: Array; +} + +declare const Array: ArrayConstructor; + +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} + +interface ArrayLike { + readonly length: number; + readonly [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). + */ + readonly byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + readonly prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): arg is ArrayBufferView; +} +declare const 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 { + readonly buffer: ArrayBuffer; + readonly byteLength: number; + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const Float64Array: Float64ArrayConstructor; +declare type PropertyKey = string | number | symbol; + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + readonly [Symbol.toStringTag]: "Symbol"; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string|number): symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: symbol): string; + + // Well-known Symbols + + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + readonly hasInstance: symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + readonly isConcatSpreadable: symbol; + + /** + * A method that returns the default iterator for an object. Called by the semantics of the + * for-of statement. + */ + readonly iterator: symbol; + + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. + */ + readonly match: symbol; + + /** + * A regular expression method that replaces matched substrings of a string. Called by the + * String.prototype.replace method. + */ + readonly replace: symbol; + + /** + * A regular expression method that returns the index within a string that matches the + * regular expression. Called by the String.prototype.search method. + */ + readonly search: symbol; + + /** + * A function valued property that is the constructor function that is used to create + * derived objects. + */ + readonly species: symbol; + + /** + * A regular expression method that splits a string at the indices that match the regular + * expression. Called by the String.prototype.split method. + */ + readonly split: symbol; + + /** + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. + */ + readonly toPrimitive: symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built-in method Object.prototype.toString. + */ + readonly toStringTag: symbol; + + /** + * An Object whose own property names are property names that are excluded from the 'with' + * environment bindings of the associated objects. + */ + readonly unscopables: symbol; +} +declare var Symbol: SymbolConstructor; + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V): T & U & V; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties + */ + assign(target: any, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface Function { + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + readonly 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 { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + readonly EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + readonly MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + readonly MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +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 + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + + /** + * 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: T, index: number, obj: Array) => boolean, thisArg?: any): T; + + /** + * 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: T) => boolean, thisArg?: any): number; + + /** + * 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: T, start?: number, end?: number): T[]; + + /** + * 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): T[]; +} + +interface IArguments { + /** Iterator */ + [Symbol.iterator](): IterableIterator; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like 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: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An 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(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface String { + /** Iterator */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + includes(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + 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 + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + +interface IteratorResult { + done: boolean; + value?: T; +} + +interface Iterator { + next(value?: any): IteratorResult; + return?(value?: any): IteratorResult; + throw?(e?: any): IteratorResult; +} + +interface Iterable { + [Symbol.iterator](): Iterator; +} + +interface IterableIterator extends Iterator { + [Symbol.iterator](): IterableIterator; +} + +interface GeneratorFunction extends Function { + readonly [Symbol.toStringTag]: "GeneratorFunction"; +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + (...args: string[]): GeneratorFunction; + readonly prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; + + readonly [Symbol.toStringTag]: "Math"; +} + +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 this regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + [Symbol.match](string: string): RegExpMatchArray; + + /** + * 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 this regular expression. + */ + [Symbol.replace](string: string, replaceValue: string): string; + + /** + * 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. + */ + [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. + * The characters in this string are sequenced and concatenated in the following order: + * + * - "g" for global + * - "i" for ignoreCase + * - "m" for multiline + * - "u" for unicode + * - "y" for sticky + * + * If no flags are set, the value is the empty string. + */ + readonly flags: string; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + readonly sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + readonly unicode: boolean; +} + +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + +interface Map { + clear(): void; + delete(key: K): boolean; + entries(): IterableIterator<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + keys(): IterableIterator; + set(key: K, value?: V): Map; + readonly size: number; + values(): IterableIterator; + [Symbol.iterator]():IterableIterator<[K,V]>; + readonly [Symbol.toStringTag]: "Map"; +} + +interface MapConstructor { + new (): Map; + new (): Map; + new (iterable: Iterable<[K, V]>): Map; + readonly prototype: Map; +} +declare var Map: MapConstructor; + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; + readonly [Symbol.toStringTag]: "WeakMap"; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; + readonly prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + entries(): IterableIterator<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + keys(): IterableIterator; + readonly size: number; + values(): IterableIterator; + [Symbol.iterator]():IterableIterator; + readonly [Symbol.toStringTag]: "Set"; +} + +interface SetConstructor { + new (): Set; + new (): Set; + new (iterable: Iterable): Set; + readonly prototype: Set; +} +declare var Set: SetConstructor; + +interface WeakSet { + add(value: T): WeakSet; + clear(): void; + delete(value: T): boolean; + has(value: T): boolean; + readonly [Symbol.toStringTag]: "WeakSet"; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (): WeakSet; + new (iterable: Iterable): WeakSet; + readonly prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + +interface JSON { + readonly [Symbol.toStringTag]: "JSON"; +} + +/** + * 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 { + readonly [Symbol.toStringTag]: "ArrayBuffer"; +} + +interface DataView { + readonly [Symbol.toStringTag]: "DataView"; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Int8Array"; +} + +interface Int8ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "UInt8Array"; +} + +interface Uint8ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Uint8ClampedArray"; +} + +interface Uint8ClampedArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + + + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Int16Array"; +} + +interface Int16ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Uint16Array"; +} + +interface Uint16ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Int32Array"; +} + +interface Int32ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Uint32Array"; +} + +interface Uint32ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Float32Array"; +} + +interface Float32ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Float64Array"; +} + +interface Float64ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} + +interface ProxyHandler { + getPrototypeOf? (target: T): any; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, thisArg: any, argArray?: any): any; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handler: ProxyHandler): T +} +declare var Proxy: ProxyConstructor; + +declare namespace Reflect { + function apply(target: Function, thisArgument: any, 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; + function get(target: any, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: any): any; + function has(target: any, propertyKey: string): boolean; + function has(target: any, propertyKey: symbol): boolean; + function isExtensible(target: any): boolean; + function ownKeys(target: any): Array; + function preventExtensions(target: any): boolean; + function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: any, proto: any): boolean; +} + +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; + + readonly [Symbol.toStringTag]: "Promise"; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Promise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; + all(values: Iterable>): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: Iterable>): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; + + readonly [Symbol.species]: Function; +} + +declare var Promise: PromiseConstructor; +interface Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: T, fromIndex?: number): boolean; +} + +interface Int8Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8ClampedArray { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int16Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint16Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float64Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} \ No newline at end of file diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 5b2c53c7cc1..68245cdefbf 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -18,8 +18,8 @@ and limitations under the License. /// ECMAScript APIs ///////////////////////////// -declare var NaN: number; -declare var Infinity: number; +declare const NaN: number; +declare const Infinity: number; /** * Evaluates JavaScript code and executes it. @@ -129,7 +129,7 @@ interface ObjectConstructor { (value: any): any; /** A reference to the prototype for a class of objects. */ - prototype: Object; + readonly prototype: Object; /** * Returns the prototype of an object. @@ -220,7 +220,7 @@ interface ObjectConstructor { /** * Provides functionality common to all JavaScript objects. */ -declare var Object: ObjectConstructor; +declare const Object: ObjectConstructor; /** * Creates a new function. @@ -249,7 +249,7 @@ interface Function { bind(thisArg: any, ...argArray: any[]): any; prototype: any; - length: number; + readonly length: number; // Non-standard extensions arguments: any; @@ -263,10 +263,10 @@ interface FunctionConstructor { */ new (...args: string[]): Function; (...args: string[]): Function; - prototype: Function; + readonly prototype: Function; } -declare var Function: FunctionConstructor; +declare const Function: FunctionConstructor; interface IArguments { [index: number]: any; @@ -414,7 +414,7 @@ interface String { trim(): string; /** Returns the length of a String object. */ - length: number; + readonly length: number; // IE extensions /** @@ -427,20 +427,20 @@ interface String { /** Returns the primitive value of the specified object. */ valueOf(): string; - [index: number]: string; + readonly [index: number]: string; } interface StringConstructor { new (value?: any): String; (value?: any): string; - prototype: String; + readonly prototype: String; fromCharCode(...codes: number[]): string; } /** * Allows manipulation and formatting of text strings and determination and location of substrings within strings. */ -declare var String: StringConstructor; +declare const String: StringConstructor; interface Boolean { /** Returns the primitive value of the specified object. */ @@ -450,10 +450,10 @@ interface Boolean { interface BooleanConstructor { new (value?: any): Boolean; (value?: any): boolean; - prototype: Boolean; + readonly prototype: Boolean; } -declare var Boolean: BooleanConstructor; +declare const Boolean: BooleanConstructor; interface Number { /** @@ -487,57 +487,57 @@ interface Number { interface NumberConstructor { new (value?: any): Number; (value?: any): number; - prototype: Number; + readonly prototype: Number; /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ - MAX_VALUE: number; + readonly MAX_VALUE: number; /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ - MIN_VALUE: number; + readonly MIN_VALUE: number; /** * A value that is not a number. * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. */ - NaN: number; + readonly NaN: number; /** * A value that is less than the largest negative number that can be represented in JavaScript. * JavaScript displays NEGATIVE_INFINITY values as -infinity. */ - NEGATIVE_INFINITY: number; + readonly NEGATIVE_INFINITY: number; /** * A value greater than the largest number that can be represented in JavaScript. * JavaScript displays POSITIVE_INFINITY values as infinity. */ - POSITIVE_INFINITY: number; + readonly POSITIVE_INFINITY: number; } /** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: NumberConstructor; +declare const Number: NumberConstructor; interface TemplateStringsArray extends Array { - raw: string[]; + readonly raw: string[]; } interface Math { /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ - E: number; + readonly E: number; /** The natural logarithm of 10. */ - LN10: number; + readonly LN10: number; /** The natural logarithm of 2. */ - LN2: number; + readonly LN2: number; /** The base-2 logarithm of e. */ - LOG2E: number; + readonly LOG2E: number; /** The base-10 logarithm of e. */ - LOG10E: number; + readonly LOG10E: number; /** Pi. This is the ratio of the circumference of a circle to its diameter. */ - PI: number; + readonly PI: number; /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ - SQRT1_2: number; + readonly SQRT1_2: number; /** The square root of 2. */ - SQRT2: number; + readonly SQRT2: number; /** * Returns the absolute value of a number (the value without regard to whether it is positive or negative). * For example, the absolute value of -5 is the same as the absolute value of 5. @@ -630,7 +630,7 @@ interface Math { tan(x: number): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ -declare var Math: Math; +declare const Math: Math; /** Enables basic storage and retrieval of dates and times. */ interface Date { @@ -792,7 +792,7 @@ interface DateConstructor { new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; (): string; - prototype: Date; + readonly prototype: Date; /** * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. * @param s A date string @@ -812,7 +812,7 @@ interface DateConstructor { now(): number; } -declare var Date: DateConstructor; +declare const Date: DateConstructor; interface RegExpMatchArray extends Array { index?: number; @@ -838,16 +838,16 @@ interface RegExp { test(string: string): boolean; /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ - source: string; + readonly source: string; /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ - global: boolean; + readonly global: boolean; /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ - ignoreCase: boolean; + readonly ignoreCase: boolean; /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ - multiline: boolean; + readonly multiline: boolean; lastIndex: number; @@ -858,7 +858,7 @@ interface RegExp { interface RegExpConstructor { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; - prototype: RegExp; + readonly prototype: RegExp; // Non-standard extensions $1: string; @@ -873,7 +873,7 @@ interface RegExpConstructor { lastMatch: string; } -declare var RegExp: RegExpConstructor; +declare const RegExp: RegExpConstructor; interface Error { name: string; @@ -883,10 +883,10 @@ interface Error { interface ErrorConstructor { new (message?: string): Error; (message?: string): Error; - prototype: Error; + readonly prototype: Error; } -declare var Error: ErrorConstructor; +declare const Error: ErrorConstructor; interface EvalError extends Error { } @@ -894,10 +894,10 @@ interface EvalError extends Error { interface EvalErrorConstructor { new (message?: string): EvalError; (message?: string): EvalError; - prototype: EvalError; + readonly prototype: EvalError; } -declare var EvalError: EvalErrorConstructor; +declare const EvalError: EvalErrorConstructor; interface RangeError extends Error { } @@ -905,10 +905,10 @@ interface RangeError extends Error { interface RangeErrorConstructor { new (message?: string): RangeError; (message?: string): RangeError; - prototype: RangeError; + readonly prototype: RangeError; } -declare var RangeError: RangeErrorConstructor; +declare const RangeError: RangeErrorConstructor; interface ReferenceError extends Error { } @@ -916,10 +916,10 @@ interface ReferenceError extends Error { interface ReferenceErrorConstructor { new (message?: string): ReferenceError; (message?: string): ReferenceError; - prototype: ReferenceError; + readonly prototype: ReferenceError; } -declare var ReferenceError: ReferenceErrorConstructor; +declare const ReferenceError: ReferenceErrorConstructor; interface SyntaxError extends Error { } @@ -927,10 +927,10 @@ interface SyntaxError extends Error { interface SyntaxErrorConstructor { new (message?: string): SyntaxError; (message?: string): SyntaxError; - prototype: SyntaxError; + readonly prototype: SyntaxError; } -declare var SyntaxError: SyntaxErrorConstructor; +declare const SyntaxError: SyntaxErrorConstructor; interface TypeError extends Error { } @@ -938,10 +938,10 @@ interface TypeError extends Error { interface TypeErrorConstructor { new (message?: string): TypeError; (message?: string): TypeError; - prototype: TypeError; + readonly prototype: TypeError; } -declare var TypeError: TypeErrorConstructor; +declare const TypeError: TypeErrorConstructor; interface URIError extends Error { } @@ -949,10 +949,10 @@ interface URIError extends Error { interface URIErrorConstructor { new (message?: string): URIError; (message?: string): URIError; - prototype: URIError; + readonly prototype: URIError; } -declare var URIError: URIErrorConstructor; +declare const URIError: URIErrorConstructor; interface JSON { /** @@ -997,13 +997,115 @@ interface JSON { /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. */ -declare var JSON: JSON; +declare const JSON: JSON; ///////////////////////////// /// ECMAScript Array API (specially handled by compiler) ///////////////////////////// +interface ReadonlyArray { + /** + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ + readonly length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat>(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * 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 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): T[]; + /** + * 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: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; + /** + * 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: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => 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: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + + readonly [n: number]: T; +} + interface Array { /** * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. @@ -1027,12 +1129,7 @@ interface Array { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; + concat(...items: (T | T[])[]): T[]; /** * 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. @@ -1052,19 +1149,16 @@ interface Array { * @param end The end of the specified portion of the array. */ slice(start?: number, end?: number): T[]; - /** * 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: T, b: T) => number): T[]; - /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. */ splice(start: number): T[]; - /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -1072,62 +1166,53 @@ interface Array { * @param items Elements to insert into the array in place of the deleted elements. */ splice(start: number, deleteCount: number, ...items: T[]): T[]; - /** * Inserts new elements at the start of an array. * @param items Elements to insert at the start of the Array. */ unshift(...items: T[]): number; - /** * 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: T, fromIndex?: number): number; - /** * Returns the index of the last occurrence of a specified value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. */ lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - /** * 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - /** * 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: T, index: number, array: T[]) => void, thisArg?: any): void; - /** * 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: T, index: number, array: T[]) => U, thisArg?: any): U[]; - /** * 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: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -1140,7 +1225,6 @@ interface Array { * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: T[]) => 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. @@ -1165,10 +1249,10 @@ interface ArrayConstructor { (arrayLength: number): T[]; (...items: T[]): T[]; isArray(arg: any): arg is Array; - prototype: Array; + readonly prototype: Array; } -declare var Array: ArrayConstructor; +declare const Array: ArrayConstructor; interface TypedPropertyDescriptor { enumerable?: boolean; @@ -1198,11 +1282,10 @@ interface PromiseLike { } interface ArrayLike { - length: number; - [n: number]: T; + readonly length: number; + readonly [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, @@ -1213,7 +1296,7 @@ interface ArrayBuffer { /** * Read-only. The length of the ArrayBuffer (in bytes). */ - byteLength: number; + readonly byteLength: number; /** * Returns a section of an ArrayBuffer. @@ -1222,11 +1305,11 @@ interface ArrayBuffer { } interface ArrayBufferConstructor { - prototype: ArrayBuffer; + readonly prototype: ArrayBuffer; new (byteLength: number): ArrayBuffer; isView(arg: any): arg is ArrayBufferView; } -declare var ArrayBuffer: ArrayBufferConstructor; +declare const ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** @@ -1246,9 +1329,9 @@ interface ArrayBufferView { } interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; + readonly buffer: ArrayBuffer; + readonly byteLength: number; + readonly 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. @@ -1376,7 +1459,7 @@ interface DataView { interface DataViewConstructor { new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; } -declare var DataView: DataViewConstructor; +declare const DataView: DataViewConstructor; /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested @@ -1386,22 +1469,22 @@ interface Int8Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -1500,7 +1583,7 @@ interface Int8Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -1624,7 +1707,7 @@ interface Int8Array { [index: number]: number; } interface Int8ArrayConstructor { - prototype: Int8Array; + readonly prototype: Int8Array; new (length: number): Int8Array; new (array: ArrayLike): Int8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; @@ -1632,7 +1715,7 @@ interface Int8ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -1649,7 +1732,7 @@ interface Int8ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; +declare const Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the @@ -1659,22 +1742,22 @@ interface Uint8Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -1773,7 +1856,7 @@ interface Uint8Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -1898,7 +1981,7 @@ interface Uint8Array { } interface Uint8ArrayConstructor { - prototype: Uint8Array; + readonly prototype: Uint8Array; new (length: number): Uint8Array; new (array: ArrayLike): Uint8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; @@ -1906,7 +1989,7 @@ interface Uint8ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -1923,7 +2006,7 @@ interface Uint8ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; +declare const Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. @@ -1933,22 +2016,22 @@ interface Uint8ClampedArray { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2047,7 +2130,7 @@ interface Uint8ClampedArray { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2172,7 +2255,7 @@ interface Uint8ClampedArray { } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; + readonly prototype: Uint8ClampedArray; new (length: number): Uint8ClampedArray; new (array: ArrayLike): Uint8ClampedArray; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; @@ -2180,7 +2263,7 @@ interface Uint8ClampedArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2196,7 +2279,7 @@ interface Uint8ClampedArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; +declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the @@ -2206,22 +2289,22 @@ interface Int16Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2320,7 +2403,7 @@ interface Int16Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2445,7 +2528,7 @@ interface Int16Array { } interface Int16ArrayConstructor { - prototype: Int16Array; + readonly prototype: Int16Array; new (length: number): Int16Array; new (array: ArrayLike): Int16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; @@ -2453,7 +2536,7 @@ interface Int16ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2470,7 +2553,7 @@ interface Int16ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; +declare const Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the @@ -2480,22 +2563,22 @@ interface Uint16Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2594,7 +2677,7 @@ interface Uint16Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2719,7 +2802,7 @@ interface Uint16Array { } interface Uint16ArrayConstructor { - prototype: Uint16Array; + readonly prototype: Uint16Array; new (length: number): Uint16Array; new (array: ArrayLike): Uint16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; @@ -2727,7 +2810,7 @@ interface Uint16ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2744,7 +2827,7 @@ interface Uint16ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; +declare const 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. @@ -2753,22 +2836,22 @@ interface Int32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2867,7 +2950,7 @@ interface Int32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2992,7 +3075,7 @@ interface Int32Array { } interface Int32ArrayConstructor { - prototype: Int32Array; + readonly prototype: Int32Array; new (length: number): Int32Array; new (array: ArrayLike): Int32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; @@ -3000,7 +3083,7 @@ interface Int32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3016,7 +3099,7 @@ interface Int32ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; +declare const Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the @@ -3026,22 +3109,22 @@ interface Uint32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3140,7 +3223,7 @@ interface Uint32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3265,7 +3348,7 @@ interface Uint32Array { } interface Uint32ArrayConstructor { - prototype: Uint32Array; + readonly prototype: Uint32Array; new (length: number): Uint32Array; new (array: ArrayLike): Uint32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; @@ -3273,7 +3356,7 @@ interface Uint32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3289,7 +3372,7 @@ interface Uint32ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; +declare const Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number @@ -3299,22 +3382,22 @@ interface Float32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3413,7 +3496,7 @@ interface Float32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3538,7 +3621,7 @@ interface Float32Array { } interface Float32ArrayConstructor { - prototype: Float32Array; + readonly prototype: Float32Array; new (length: number): Float32Array; new (array: ArrayLike): Float32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; @@ -3546,7 +3629,7 @@ interface Float32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3563,7 +3646,7 @@ interface Float32ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; +declare const Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested @@ -3573,22 +3656,22 @@ interface Float64Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3687,7 +3770,7 @@ interface Float64Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3812,7 +3895,7 @@ interface Float64Array { } interface Float64ArrayConstructor { - prototype: Float64Array; + readonly prototype: Float64Array; new (length: number): Float64Array; new (array: ArrayLike): Float64Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; @@ -3820,7 +3903,7 @@ interface Float64ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3836,7 +3919,7 @@ interface Float64ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; +declare const Float64Array: Float64ArrayConstructor; ///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -4418,6 +4501,8 @@ interface AudioNode extends EventTarget { numberOfOutputs: number; connect(destination: AudioNode, output?: number, input?: number): void; disconnect(output?: number): void; + disconnect(destination: AudioNode, output?: number, input?: number): void; + disconnect(destination: AudioParam, output?: number): void; } declare var AudioNode: { @@ -10934,7 +11019,7 @@ interface IDBCursor { direction: string; key: any; primaryKey: any; - source: any; + source: IDBObjectStore | IDBIndex; advance(count: number): void; continue(key?: any): void; delete(): IDBRequest; @@ -10972,7 +11057,7 @@ interface IDBDatabase extends EventTarget { close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; - transaction(storeNames: any, mode?: string): IDBTransaction; + transaction(storeNames: string | string[], mode?: string): IDBTransaction; 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; @@ -11030,9 +11115,10 @@ declare var IDBKeyRange: { interface IDBObjectStore { indexNames: DOMStringList; - keyPath: string; + keyPath: string | string[]; name: string; transaction: IDBTransaction; + autoIncrement: boolean; add(value: any, key?: any): IDBRequest; clear(): IDBRequest; count(key?: any): IDBRequest; @@ -11071,7 +11157,7 @@ interface IDBRequest extends EventTarget { onsuccess: (ev: Event) => any; readyState: string; result: any; - source: any; + source: IDBObjectStore | IDBIndex | IDBCursor; transaction: IDBTransaction; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -14258,11 +14344,14 @@ declare var SVGViewElement: { } interface SVGZoomAndPan { + zoomAndPan: number; +} + +declare var SVGZoomAndPan: { SVG_ZOOMANDPAN_DISABLE: number; SVG_ZOOMANDPAN_MAGNIFY: number; SVG_ZOOMANDPAN_UNKNOWN: number; } -declare var SVGZoomAndPan: SVGZoomAndPan; interface SVGZoomEvent extends UIEvent { newScale: number; @@ -16725,7 +16814,7 @@ interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; } interface DecodeErrorCallback { - (): void; + (error: DOMException): void; } interface FunctionStringCallback { (data: string): void; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 542149d7719..7bb2e8d4158 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -595,6 +595,8 @@ interface AudioNode extends EventTarget { numberOfOutputs: number; connect(destination: AudioNode, output?: number, input?: number): void; disconnect(output?: number): void; + disconnect(destination: AudioNode, output?: number, input?: number): void; + disconnect(destination: AudioParam, output?: number): void; } declare var AudioNode: { @@ -7111,7 +7113,7 @@ interface IDBCursor { direction: string; key: any; primaryKey: any; - source: any; + source: IDBObjectStore | IDBIndex; advance(count: number): void; continue(key?: any): void; delete(): IDBRequest; @@ -7149,7 +7151,7 @@ interface IDBDatabase extends EventTarget { close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; - transaction(storeNames: any, mode?: string): IDBTransaction; + transaction(storeNames: string | string[], mode?: string): IDBTransaction; 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; @@ -7207,9 +7209,10 @@ declare var IDBKeyRange: { interface IDBObjectStore { indexNames: DOMStringList; - keyPath: string; + keyPath: string | string[]; name: string; transaction: IDBTransaction; + autoIncrement: boolean; add(value: any, key?: any): IDBRequest; clear(): IDBRequest; count(key?: any): IDBRequest; @@ -7248,7 +7251,7 @@ interface IDBRequest extends EventTarget { onsuccess: (ev: Event) => any; readyState: string; result: any; - source: any; + source: IDBObjectStore | IDBIndex | IDBCursor; transaction: IDBTransaction; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -10435,11 +10438,14 @@ declare var SVGViewElement: { } interface SVGZoomAndPan { + zoomAndPan: number; +} + +declare var SVGZoomAndPan: { SVG_ZOOMANDPAN_DISABLE: number; SVG_ZOOMANDPAN_MAGNIFY: number; SVG_ZOOMANDPAN_UNKNOWN: number; } -declare var SVGZoomAndPan: SVGZoomAndPan; interface SVGZoomEvent extends UIEvent { newScale: number; @@ -12902,7 +12908,7 @@ interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; } interface DecodeErrorCallback { - (): void; + (error: DOMException): void; } interface FunctionStringCallback { (data: string): void; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 70f464ad48e..7e973a82820 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -23,14 +23,14 @@ interface Symbol { /** Returns the primitive value of the specified object. */ valueOf(): Object; - [Symbol.toStringTag]: "Symbol"; + readonly [Symbol.toStringTag]: "Symbol"; } interface SymbolConstructor { /** * A reference to the prototype. */ - prototype: Symbol; + readonly prototype: Symbol; /** * Returns a new unique Symbol value. @@ -58,67 +58,67 @@ interface SymbolConstructor { * A method that determines if a constructor object recognizes an object as one of the * constructor’s instances. Called by the semantics of the instanceof operator. */ - hasInstance: symbol; + readonly hasInstance: symbol; /** * A Boolean value that if true indicates that an object should flatten to its array elements * by Array.prototype.concat. */ - isConcatSpreadable: symbol; + readonly isConcatSpreadable: symbol; /** * A method that returns the default iterator for an object. Called by the semantics of the * for-of statement. */ - iterator: symbol; + readonly iterator: symbol; /** * A regular expression method that matches the regular expression against a string. Called * by the String.prototype.match method. */ - match: symbol; + readonly match: symbol; /** * A regular expression method that replaces matched substrings of a string. Called by the * String.prototype.replace method. */ - replace: symbol; + readonly replace: symbol; /** * A regular expression method that returns the index within a string that matches the * regular expression. Called by the String.prototype.search method. */ - search: symbol; + readonly search: symbol; /** * A function valued property that is the constructor function that is used to create * derived objects. */ - species: symbol; + readonly species: symbol; /** * A regular expression method that splits a string at the indices that match the regular * expression. Called by the String.prototype.split method. */ - split: symbol; + readonly split: symbol; /** * A method that converts an object to a corresponding primitive value. * Called by the ToPrimitive abstract operation. */ - toPrimitive: symbol; + readonly toPrimitive: symbol; /** * A String value that is used in the creation of the default string description of an object. * Called by the built-in method Object.prototype.toString. */ - toStringTag: symbol; + readonly toStringTag: symbol; /** * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ - unscopables: symbol; + readonly unscopables: symbol; } declare var Symbol: SymbolConstructor; @@ -216,7 +216,7 @@ interface Function { /** * Returns the name of the function. Function names are read-only and can not be changed. */ - name: string; + readonly name: string; /** * Determines whether the given value inherits from this function if this function was used @@ -234,7 +234,7 @@ interface NumberConstructor { * that is representable as a Number value, which is approximately: * 2.2204460492503130808472633361816 x 10‍−‍16. */ - EPSILON: number; + readonly EPSILON: number; /** * Returns true if passed value is finite. @@ -269,14 +269,14 @@ interface NumberConstructor { * a Number value. * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. */ - MAX_SAFE_INTEGER: number; + readonly MAX_SAFE_INTEGER: number; /** * The value of the smallest integer n such that n and n − 1 are both exactly representable as * a Number value. * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). */ - MIN_SAFE_INTEGER: number; + readonly MIN_SAFE_INTEGER: number; /** * Converts a string to a floating-point number. @@ -581,7 +581,7 @@ interface IterableIterator extends Iterator { } interface GeneratorFunction extends Function { - [Symbol.toStringTag]: "GeneratorFunction"; + readonly [Symbol.toStringTag]: "GeneratorFunction"; } interface GeneratorFunctionConstructor { @@ -591,7 +591,7 @@ interface GeneratorFunctionConstructor { */ new (...args: string[]): GeneratorFunction; (...args: string[]): GeneratorFunction; - prototype: GeneratorFunction; + readonly prototype: GeneratorFunction; } declare var GeneratorFunction: GeneratorFunctionConstructor; @@ -706,7 +706,7 @@ interface Math { */ cbrt(x: number): number; - [Symbol.toStringTag]: "Math"; + readonly [Symbol.toStringTag]: "Math"; } interface Date { @@ -792,19 +792,19 @@ interface RegExp { * * If no flags are set, the value is the empty string. */ - flags: string; + readonly flags: string; /** * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular * expression. Default is false. Read-only. */ - sticky: boolean; + readonly sticky: boolean; /** * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular * expression. Default is false. Read-only. */ - unicode: boolean; + readonly unicode: boolean; } interface RegExpConstructor { @@ -820,17 +820,17 @@ interface Map { has(key: K): boolean; keys(): IterableIterator; set(key: K, value?: V): Map; - size: number; + readonly size: number; values(): IterableIterator; [Symbol.iterator]():IterableIterator<[K,V]>; - [Symbol.toStringTag]: "Map"; + readonly [Symbol.toStringTag]: "Map"; } interface MapConstructor { new (): Map; new (): Map; new (iterable: Iterable<[K, V]>): Map; - prototype: Map; + readonly prototype: Map; } declare var Map: MapConstructor; @@ -840,14 +840,14 @@ interface WeakMap { get(key: K): V; has(key: K): boolean; set(key: K, value?: V): WeakMap; - [Symbol.toStringTag]: "WeakMap"; + readonly [Symbol.toStringTag]: "WeakMap"; } interface WeakMapConstructor { new (): WeakMap; new (): WeakMap; new (iterable: Iterable<[K, V]>): WeakMap; - prototype: WeakMap; + readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -859,17 +859,17 @@ interface Set { forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; has(value: T): boolean; keys(): IterableIterator; - size: number; + readonly size: number; values(): IterableIterator; [Symbol.iterator]():IterableIterator; - [Symbol.toStringTag]: "Set"; + readonly [Symbol.toStringTag]: "Set"; } interface SetConstructor { new (): Set; new (): Set; new (iterable: Iterable): Set; - prototype: Set; + readonly prototype: Set; } declare var Set: SetConstructor; @@ -878,19 +878,19 @@ interface WeakSet { clear(): void; delete(value: T): boolean; has(value: T): boolean; - [Symbol.toStringTag]: "WeakSet"; + readonly [Symbol.toStringTag]: "WeakSet"; } interface WeakSetConstructor { new (): WeakSet; new (): WeakSet; new (iterable: Iterable): WeakSet; - prototype: WeakSet; + readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; interface JSON { - [Symbol.toStringTag]: "JSON"; + readonly [Symbol.toStringTag]: "JSON"; } /** @@ -900,11 +900,11 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - [Symbol.toStringTag]: "ArrayBuffer"; + readonly [Symbol.toStringTag]: "ArrayBuffer"; } interface DataView { - [Symbol.toStringTag]: "DataView"; + readonly [Symbol.toStringTag]: "DataView"; } /** @@ -925,7 +925,7 @@ interface Int8Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Int8Array"; + readonly [Symbol.toStringTag]: "Int8Array"; } interface Int8ArrayConstructor { @@ -958,7 +958,7 @@ interface Uint8Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "UInt8Array"; + readonly [Symbol.toStringTag]: "UInt8Array"; } interface Uint8ArrayConstructor { @@ -994,7 +994,7 @@ interface Uint8ClampedArray { values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Uint8ClampedArray"; + readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } interface Uint8ClampedArrayConstructor { @@ -1032,7 +1032,7 @@ interface Int16Array { [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Int16Array"; + readonly [Symbol.toStringTag]: "Int16Array"; } interface Int16ArrayConstructor { @@ -1065,7 +1065,7 @@ interface Uint16Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Uint16Array"; + readonly [Symbol.toStringTag]: "Uint16Array"; } interface Uint16ArrayConstructor { @@ -1098,7 +1098,7 @@ interface Int32Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Int32Array"; + readonly [Symbol.toStringTag]: "Int32Array"; } interface Int32ArrayConstructor { @@ -1131,7 +1131,7 @@ interface Uint32Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Uint32Array"; + readonly [Symbol.toStringTag]: "Uint32Array"; } interface Uint32ArrayConstructor { @@ -1164,7 +1164,7 @@ interface Float32Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Float32Array"; + readonly [Symbol.toStringTag]: "Float32Array"; } interface Float32ArrayConstructor { @@ -1197,7 +1197,7 @@ interface Float64Array { */ values(): IterableIterator; [Symbol.iterator](): IterableIterator; - [Symbol.toStringTag]: "Float64Array"; + readonly [Symbol.toStringTag]: "Float64Array"; } interface Float64ArrayConstructor { @@ -1274,14 +1274,14 @@ interface Promise { catch(onrejected?: (reason: any) => T | PromiseLike): Promise; catch(onrejected?: (reason: any) => void): Promise; - [Symbol.toStringTag]: "Promise"; + readonly [Symbol.toStringTag]: "Promise"; } interface PromiseConstructor { /** * A reference to the prototype. */ - prototype: Promise; + readonly prototype: Promise; /** * Creates a new Promise. @@ -1343,7 +1343,7 @@ interface PromiseConstructor { */ resolve(): Promise; - [Symbol.species]: Function; + readonly [Symbol.species]: Function; } declare var Promise: PromiseConstructor; @@ -1351,8 +1351,8 @@ declare var Promise: PromiseConstructor; /// ECMAScript APIs ///////////////////////////// -declare var NaN: number; -declare var Infinity: number; +declare const NaN: number; +declare const Infinity: number; /** * Evaluates JavaScript code and executes it. @@ -1462,7 +1462,7 @@ interface ObjectConstructor { (value: any): any; /** A reference to the prototype for a class of objects. */ - prototype: Object; + readonly prototype: Object; /** * Returns the prototype of an object. @@ -1553,7 +1553,7 @@ interface ObjectConstructor { /** * Provides functionality common to all JavaScript objects. */ -declare var Object: ObjectConstructor; +declare const Object: ObjectConstructor; /** * Creates a new function. @@ -1582,7 +1582,7 @@ interface Function { bind(thisArg: any, ...argArray: any[]): any; prototype: any; - length: number; + readonly length: number; // Non-standard extensions arguments: any; @@ -1596,10 +1596,10 @@ interface FunctionConstructor { */ new (...args: string[]): Function; (...args: string[]): Function; - prototype: Function; + readonly prototype: Function; } -declare var Function: FunctionConstructor; +declare const Function: FunctionConstructor; interface IArguments { [index: number]: any; @@ -1747,7 +1747,7 @@ interface String { trim(): string; /** Returns the length of a String object. */ - length: number; + readonly length: number; // IE extensions /** @@ -1760,20 +1760,20 @@ interface String { /** Returns the primitive value of the specified object. */ valueOf(): string; - [index: number]: string; + readonly [index: number]: string; } interface StringConstructor { new (value?: any): String; (value?: any): string; - prototype: String; + readonly prototype: String; fromCharCode(...codes: number[]): string; } /** * Allows manipulation and formatting of text strings and determination and location of substrings within strings. */ -declare var String: StringConstructor; +declare const String: StringConstructor; interface Boolean { /** Returns the primitive value of the specified object. */ @@ -1783,10 +1783,10 @@ interface Boolean { interface BooleanConstructor { new (value?: any): Boolean; (value?: any): boolean; - prototype: Boolean; + readonly prototype: Boolean; } -declare var Boolean: BooleanConstructor; +declare const Boolean: BooleanConstructor; interface Number { /** @@ -1820,57 +1820,57 @@ interface Number { interface NumberConstructor { new (value?: any): Number; (value?: any): number; - prototype: Number; + readonly prototype: Number; /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ - MAX_VALUE: number; + readonly MAX_VALUE: number; /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ - MIN_VALUE: number; + readonly MIN_VALUE: number; /** * A value that is not a number. * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. */ - NaN: number; + readonly NaN: number; /** * A value that is less than the largest negative number that can be represented in JavaScript. * JavaScript displays NEGATIVE_INFINITY values as -infinity. */ - NEGATIVE_INFINITY: number; + readonly NEGATIVE_INFINITY: number; /** * A value greater than the largest number that can be represented in JavaScript. * JavaScript displays POSITIVE_INFINITY values as infinity. */ - POSITIVE_INFINITY: number; + readonly POSITIVE_INFINITY: number; } /** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: NumberConstructor; +declare const Number: NumberConstructor; interface TemplateStringsArray extends Array { - raw: string[]; + readonly raw: string[]; } interface Math { /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ - E: number; + readonly E: number; /** The natural logarithm of 10. */ - LN10: number; + readonly LN10: number; /** The natural logarithm of 2. */ - LN2: number; + readonly LN2: number; /** The base-2 logarithm of e. */ - LOG2E: number; + readonly LOG2E: number; /** The base-10 logarithm of e. */ - LOG10E: number; + readonly LOG10E: number; /** Pi. This is the ratio of the circumference of a circle to its diameter. */ - PI: number; + readonly PI: number; /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ - SQRT1_2: number; + readonly SQRT1_2: number; /** The square root of 2. */ - SQRT2: number; + readonly SQRT2: number; /** * Returns the absolute value of a number (the value without regard to whether it is positive or negative). * For example, the absolute value of -5 is the same as the absolute value of 5. @@ -1963,7 +1963,7 @@ interface Math { tan(x: number): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ -declare var Math: Math; +declare const Math: Math; /** Enables basic storage and retrieval of dates and times. */ interface Date { @@ -2125,7 +2125,7 @@ interface DateConstructor { new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; (): string; - prototype: Date; + readonly prototype: Date; /** * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. * @param s A date string @@ -2145,7 +2145,7 @@ interface DateConstructor { now(): number; } -declare var Date: DateConstructor; +declare const Date: DateConstructor; interface RegExpMatchArray extends Array { index?: number; @@ -2171,16 +2171,16 @@ interface RegExp { test(string: string): boolean; /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ - source: string; + readonly source: string; /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ - global: boolean; + readonly global: boolean; /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ - ignoreCase: boolean; + readonly ignoreCase: boolean; /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ - multiline: boolean; + readonly multiline: boolean; lastIndex: number; @@ -2191,7 +2191,7 @@ interface RegExp { interface RegExpConstructor { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; - prototype: RegExp; + readonly prototype: RegExp; // Non-standard extensions $1: string; @@ -2206,7 +2206,7 @@ interface RegExpConstructor { lastMatch: string; } -declare var RegExp: RegExpConstructor; +declare const RegExp: RegExpConstructor; interface Error { name: string; @@ -2216,10 +2216,10 @@ interface Error { interface ErrorConstructor { new (message?: string): Error; (message?: string): Error; - prototype: Error; + readonly prototype: Error; } -declare var Error: ErrorConstructor; +declare const Error: ErrorConstructor; interface EvalError extends Error { } @@ -2227,10 +2227,10 @@ interface EvalError extends Error { interface EvalErrorConstructor { new (message?: string): EvalError; (message?: string): EvalError; - prototype: EvalError; + readonly prototype: EvalError; } -declare var EvalError: EvalErrorConstructor; +declare const EvalError: EvalErrorConstructor; interface RangeError extends Error { } @@ -2238,10 +2238,10 @@ interface RangeError extends Error { interface RangeErrorConstructor { new (message?: string): RangeError; (message?: string): RangeError; - prototype: RangeError; + readonly prototype: RangeError; } -declare var RangeError: RangeErrorConstructor; +declare const RangeError: RangeErrorConstructor; interface ReferenceError extends Error { } @@ -2249,10 +2249,10 @@ interface ReferenceError extends Error { interface ReferenceErrorConstructor { new (message?: string): ReferenceError; (message?: string): ReferenceError; - prototype: ReferenceError; + readonly prototype: ReferenceError; } -declare var ReferenceError: ReferenceErrorConstructor; +declare const ReferenceError: ReferenceErrorConstructor; interface SyntaxError extends Error { } @@ -2260,10 +2260,10 @@ interface SyntaxError extends Error { interface SyntaxErrorConstructor { new (message?: string): SyntaxError; (message?: string): SyntaxError; - prototype: SyntaxError; + readonly prototype: SyntaxError; } -declare var SyntaxError: SyntaxErrorConstructor; +declare const SyntaxError: SyntaxErrorConstructor; interface TypeError extends Error { } @@ -2271,10 +2271,10 @@ interface TypeError extends Error { interface TypeErrorConstructor { new (message?: string): TypeError; (message?: string): TypeError; - prototype: TypeError; + readonly prototype: TypeError; } -declare var TypeError: TypeErrorConstructor; +declare const TypeError: TypeErrorConstructor; interface URIError extends Error { } @@ -2282,10 +2282,10 @@ interface URIError extends Error { interface URIErrorConstructor { new (message?: string): URIError; (message?: string): URIError; - prototype: URIError; + readonly prototype: URIError; } -declare var URIError: URIErrorConstructor; +declare const URIError: URIErrorConstructor; interface JSON { /** @@ -2330,13 +2330,115 @@ interface JSON { /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. */ -declare var JSON: JSON; +declare const JSON: JSON; ///////////////////////////// /// ECMAScript Array API (specially handled by compiler) ///////////////////////////// +interface ReadonlyArray { + /** + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ + readonly length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat>(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * 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 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): T[]; + /** + * 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: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; + /** + * 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: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => 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: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + + readonly [n: number]: T; +} + interface Array { /** * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. @@ -2360,12 +2462,7 @@ interface Array { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; + concat(...items: (T | T[])[]): T[]; /** * 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. @@ -2385,19 +2482,16 @@ interface Array { * @param end The end of the specified portion of the array. */ slice(start?: number, end?: number): T[]; - /** * 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: T, b: T) => number): T[]; - /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. */ splice(start: number): T[]; - /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -2405,62 +2499,53 @@ interface Array { * @param items Elements to insert into the array in place of the deleted elements. */ splice(start: number, deleteCount: number, ...items: T[]): T[]; - /** * Inserts new elements at the start of an array. * @param items Elements to insert at the start of the Array. */ unshift(...items: T[]): number; - /** * 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: T, fromIndex?: number): number; - /** * Returns the index of the last occurrence of a specified value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. */ lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - /** * 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - /** * 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: T, index: number, array: T[]) => void, thisArg?: any): void; - /** * 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: T, index: number, array: T[]) => U, thisArg?: any): U[]; - /** * 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: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -2473,7 +2558,6 @@ interface Array { * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: T[]) => 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. @@ -2498,10 +2582,10 @@ interface ArrayConstructor { (arrayLength: number): T[]; (...items: T[]): T[]; isArray(arg: any): arg is Array; - prototype: Array; + readonly prototype: Array; } -declare var Array: ArrayConstructor; +declare const Array: ArrayConstructor; interface TypedPropertyDescriptor { enumerable?: boolean; @@ -2531,11 +2615,10 @@ interface PromiseLike { } interface ArrayLike { - length: number; - [n: number]: T; + readonly length: number; + readonly [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, @@ -2546,7 +2629,7 @@ interface ArrayBuffer { /** * Read-only. The length of the ArrayBuffer (in bytes). */ - byteLength: number; + readonly byteLength: number; /** * Returns a section of an ArrayBuffer. @@ -2555,11 +2638,11 @@ interface ArrayBuffer { } interface ArrayBufferConstructor { - prototype: ArrayBuffer; + readonly prototype: ArrayBuffer; new (byteLength: number): ArrayBuffer; isView(arg: any): arg is ArrayBufferView; } -declare var ArrayBuffer: ArrayBufferConstructor; +declare const ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** @@ -2579,9 +2662,9 @@ interface ArrayBufferView { } interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; + readonly buffer: ArrayBuffer; + readonly byteLength: number; + readonly 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. @@ -2709,7 +2792,7 @@ interface DataView { interface DataViewConstructor { new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; } -declare var DataView: DataViewConstructor; +declare const DataView: DataViewConstructor; /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested @@ -2719,22 +2802,22 @@ interface Int8Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -2833,7 +2916,7 @@ interface Int8Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -2957,7 +3040,7 @@ interface Int8Array { [index: number]: number; } interface Int8ArrayConstructor { - prototype: Int8Array; + readonly prototype: Int8Array; new (length: number): Int8Array; new (array: ArrayLike): Int8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; @@ -2965,7 +3048,7 @@ interface Int8ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -2982,7 +3065,7 @@ interface Int8ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; +declare const Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the @@ -2992,22 +3075,22 @@ interface Uint8Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3106,7 +3189,7 @@ interface Uint8Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3231,7 +3314,7 @@ interface Uint8Array { } interface Uint8ArrayConstructor { - prototype: Uint8Array; + readonly prototype: Uint8Array; new (length: number): Uint8Array; new (array: ArrayLike): Uint8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; @@ -3239,7 +3322,7 @@ interface Uint8ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3256,7 +3339,7 @@ interface Uint8ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; +declare const Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. @@ -3266,22 +3349,22 @@ interface Uint8ClampedArray { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3380,7 +3463,7 @@ interface Uint8ClampedArray { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3505,7 +3588,7 @@ interface Uint8ClampedArray { } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; + readonly prototype: Uint8ClampedArray; new (length: number): Uint8ClampedArray; new (array: ArrayLike): Uint8ClampedArray; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; @@ -3513,7 +3596,7 @@ interface Uint8ClampedArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3529,7 +3612,7 @@ interface Uint8ClampedArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; +declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the @@ -3539,22 +3622,22 @@ interface Int16Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3653,7 +3736,7 @@ interface Int16Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -3778,7 +3861,7 @@ interface Int16Array { } interface Int16ArrayConstructor { - prototype: Int16Array; + readonly prototype: Int16Array; new (length: number): Int16Array; new (array: ArrayLike): Int16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; @@ -3786,7 +3869,7 @@ interface Int16ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -3803,7 +3886,7 @@ interface Int16ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; +declare const Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the @@ -3813,22 +3896,22 @@ interface Uint16Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -3927,7 +4010,7 @@ interface Uint16Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -4052,7 +4135,7 @@ interface Uint16Array { } interface Uint16ArrayConstructor { - prototype: Uint16Array; + readonly prototype: Uint16Array; new (length: number): Uint16Array; new (array: ArrayLike): Uint16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; @@ -4060,7 +4143,7 @@ interface Uint16ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -4077,7 +4160,7 @@ interface Uint16ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; +declare const 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. @@ -4086,22 +4169,22 @@ interface Int32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -4200,7 +4283,7 @@ interface Int32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -4325,7 +4408,7 @@ interface Int32Array { } interface Int32ArrayConstructor { - prototype: Int32Array; + readonly prototype: Int32Array; new (length: number): Int32Array; new (array: ArrayLike): Int32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; @@ -4333,7 +4416,7 @@ interface Int32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -4349,7 +4432,7 @@ interface Int32ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; +declare const Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the @@ -4359,22 +4442,22 @@ interface Uint32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -4473,7 +4556,7 @@ interface Uint32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -4598,7 +4681,7 @@ interface Uint32Array { } interface Uint32ArrayConstructor { - prototype: Uint32Array; + readonly prototype: Uint32Array; new (length: number): Uint32Array; new (array: ArrayLike): Uint32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; @@ -4606,7 +4689,7 @@ interface Uint32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -4622,7 +4705,7 @@ interface Uint32ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; +declare const Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number @@ -4632,22 +4715,22 @@ interface Float32Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -4746,7 +4829,7 @@ interface Float32Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -4871,7 +4954,7 @@ interface Float32Array { } interface Float32ArrayConstructor { - prototype: Float32Array; + readonly prototype: Float32Array; new (length: number): Float32Array; new (array: ArrayLike): Float32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; @@ -4879,7 +4962,7 @@ interface Float32ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -4896,7 +4979,7 @@ interface Float32ArrayConstructor { from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; +declare const Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested @@ -4906,22 +4989,22 @@ interface Float64Array { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + readonly buffer: ArrayBuffer; /** * The length in bytes of the array. */ - byteLength: number; + readonly byteLength: number; /** * The offset in bytes of the array. */ - byteOffset: number; + readonly byteOffset: number; /** * Returns the this object after copying a section of the array identified by start and end @@ -5020,7 +5103,7 @@ interface Float64Array { /** * The length of the array. */ - length: number; + readonly length: number; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -5145,7 +5228,7 @@ interface Float64Array { } interface Float64ArrayConstructor { - prototype: Float64Array; + readonly prototype: Float64Array; new (length: number): Float64Array; new (array: ArrayLike): Float64Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; @@ -5153,7 +5236,7 @@ interface Float64ArrayConstructor { /** * The size in bytes of each element in the array. */ - BYTES_PER_ELEMENT: number; + readonly BYTES_PER_ELEMENT: number; /** * Returns a new array from a set of elements. @@ -5169,7 +5252,7 @@ interface Float64ArrayConstructor { */ from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; +declare const Float64Array: Float64ArrayConstructor; ///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -5751,6 +5834,8 @@ interface AudioNode extends EventTarget { numberOfOutputs: number; connect(destination: AudioNode, output?: number, input?: number): void; disconnect(output?: number): void; + disconnect(destination: AudioNode, output?: number, input?: number): void; + disconnect(destination: AudioParam, output?: number): void; } declare var AudioNode: { @@ -12267,7 +12352,7 @@ interface IDBCursor { direction: string; key: any; primaryKey: any; - source: any; + source: IDBObjectStore | IDBIndex; advance(count: number): void; continue(key?: any): void; delete(): IDBRequest; @@ -12305,7 +12390,7 @@ interface IDBDatabase extends EventTarget { close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; - transaction(storeNames: any, mode?: string): IDBTransaction; + transaction(storeNames: string | string[], mode?: string): IDBTransaction; 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; @@ -12363,9 +12448,10 @@ declare var IDBKeyRange: { interface IDBObjectStore { indexNames: DOMStringList; - keyPath: string; + keyPath: string | string[]; name: string; transaction: IDBTransaction; + autoIncrement: boolean; add(value: any, key?: any): IDBRequest; clear(): IDBRequest; count(key?: any): IDBRequest; @@ -12404,7 +12490,7 @@ interface IDBRequest extends EventTarget { onsuccess: (ev: Event) => any; readyState: string; result: any; - source: any; + source: IDBObjectStore | IDBIndex | IDBCursor; transaction: IDBTransaction; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -15591,11 +15677,14 @@ declare var SVGViewElement: { } interface SVGZoomAndPan { + zoomAndPan: number; +} + +declare var SVGZoomAndPan: { SVG_ZOOMANDPAN_DISABLE: number; SVG_ZOOMANDPAN_MAGNIFY: number; SVG_ZOOMANDPAN_UNKNOWN: number; } -declare var SVGZoomAndPan: SVGZoomAndPan; interface SVGZoomEvent extends UIEvent { newScale: number; @@ -18058,7 +18147,7 @@ interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; } interface DecodeErrorCallback { - (): void; + (error: DOMException): void; } interface FunctionStringCallback { (data: string): void; diff --git a/lib/lib.es7.d.ts b/lib/lib.es7.d.ts new file mode 100644 index 00000000000..4da974fb3bc --- /dev/null +++ b/lib/lib.es7.d.ts @@ -0,0 +1,18829 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// +declare type PropertyKey = string | number | symbol; + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + readonly [Symbol.toStringTag]: "Symbol"; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string|number): symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: symbol): string; + + // Well-known Symbols + + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + readonly hasInstance: symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + readonly isConcatSpreadable: symbol; + + /** + * A method that returns the default iterator for an object. Called by the semantics of the + * for-of statement. + */ + readonly iterator: symbol; + + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. + */ + readonly match: symbol; + + /** + * A regular expression method that replaces matched substrings of a string. Called by the + * String.prototype.replace method. + */ + readonly replace: symbol; + + /** + * A regular expression method that returns the index within a string that matches the + * regular expression. Called by the String.prototype.search method. + */ + readonly search: symbol; + + /** + * A function valued property that is the constructor function that is used to create + * derived objects. + */ + readonly species: symbol; + + /** + * A regular expression method that splits a string at the indices that match the regular + * expression. Called by the String.prototype.split method. + */ + readonly split: symbol; + + /** + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. + */ + readonly toPrimitive: symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built-in method Object.prototype.toString. + */ + readonly toStringTag: symbol; + + /** + * An Object whose own property names are property names that are excluded from the 'with' + * environment bindings of the associated objects. + */ + readonly unscopables: symbol; +} +declare var Symbol: SymbolConstructor; + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V): T & U & V; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties + */ + assign(target: any, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface Function { + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + readonly 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 { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + readonly EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + readonly MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + readonly MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string): number; + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +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 + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + + /** + * 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: T, index: number, obj: Array) => boolean, thisArg?: any): T; + + /** + * 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: T) => boolean, thisArg?: any): number; + + /** + * 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: T, start?: number, end?: number): T[]; + + /** + * 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): T[]; +} + +interface IArguments { + /** Iterator */ + [Symbol.iterator](): IterableIterator; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like 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: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An 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(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface String { + /** Iterator */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + includes(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + 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 + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]): string; +} + +interface IteratorResult { + done: boolean; + value?: T; +} + +interface Iterator { + next(value?: any): IteratorResult; + return?(value?: any): IteratorResult; + throw?(e?: any): IteratorResult; +} + +interface Iterable { + [Symbol.iterator](): Iterator; +} + +interface IterableIterator extends Iterator { + [Symbol.iterator](): IterableIterator; +} + +interface GeneratorFunction extends Function { + readonly [Symbol.toStringTag]: "GeneratorFunction"; +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + (...args: string[]): GeneratorFunction; + readonly prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; + + readonly [Symbol.toStringTag]: "Math"; +} + +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 this regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + [Symbol.match](string: string): RegExpMatchArray; + + /** + * 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 this regular expression. + */ + [Symbol.replace](string: string, replaceValue: string): string; + + /** + * 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. + */ + [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. + * The characters in this string are sequenced and concatenated in the following order: + * + * - "g" for global + * - "i" for ignoreCase + * - "m" for multiline + * - "u" for unicode + * - "y" for sticky + * + * If no flags are set, the value is the empty string. + */ + readonly flags: string; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + readonly sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + readonly unicode: boolean; +} + +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + +interface Map { + clear(): void; + delete(key: K): boolean; + entries(): IterableIterator<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + keys(): IterableIterator; + set(key: K, value?: V): Map; + readonly size: number; + values(): IterableIterator; + [Symbol.iterator]():IterableIterator<[K,V]>; + readonly [Symbol.toStringTag]: "Map"; +} + +interface MapConstructor { + new (): Map; + new (): Map; + new (iterable: Iterable<[K, V]>): Map; + readonly prototype: Map; +} +declare var Map: MapConstructor; + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; + readonly [Symbol.toStringTag]: "WeakMap"; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; + readonly prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + entries(): IterableIterator<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + keys(): IterableIterator; + readonly size: number; + values(): IterableIterator; + [Symbol.iterator]():IterableIterator; + readonly [Symbol.toStringTag]: "Set"; +} + +interface SetConstructor { + new (): Set; + new (): Set; + new (iterable: Iterable): Set; + readonly prototype: Set; +} +declare var Set: SetConstructor; + +interface WeakSet { + add(value: T): WeakSet; + clear(): void; + delete(value: T): boolean; + has(value: T): boolean; + readonly [Symbol.toStringTag]: "WeakSet"; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (): WeakSet; + new (iterable: Iterable): WeakSet; + readonly prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + +interface JSON { + readonly [Symbol.toStringTag]: "JSON"; +} + +/** + * 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 { + readonly [Symbol.toStringTag]: "ArrayBuffer"; +} + +interface DataView { + readonly [Symbol.toStringTag]: "DataView"; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Int8Array"; +} + +interface Int8ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "UInt8Array"; +} + +interface Uint8ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Uint8ClampedArray"; +} + +interface Uint8ClampedArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + + + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Int16Array"; +} + +interface Int16ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Uint16Array"; +} + +interface Uint16ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Int32Array"; +} + +interface Int32ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Uint32Array"; +} + +interface Uint32ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Float32Array"; +} + +interface Float32ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; +} + +/** + * 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 { + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, number]>; + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + /** + * Returns an list of values in the array + */ + values(): IterableIterator; + [Symbol.iterator](): IterableIterator; + readonly [Symbol.toStringTag]: "Float64Array"; +} + +interface Float64ArrayConstructor { + new (elements: Iterable): 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: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} + +interface ProxyHandler { + getPrototypeOf? (target: T): any; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, thisArg: any, argArray?: any): any; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handler: ProxyHandler): T +} +declare var Proxy: ProxyConstructor; + +declare namespace Reflect { + function apply(target: Function, thisArgument: any, 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; + function get(target: any, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: any): any; + function has(target: any, propertyKey: string): boolean; + function has(target: any, propertyKey: symbol): boolean; + function isExtensible(target: any): boolean; + function ownKeys(target: any): Array; + function preventExtensions(target: any): boolean; + function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: any, proto: any): boolean; +} + +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; + + readonly [Symbol.toStringTag]: "Promise"; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + readonly prototype: Promise; + + /** + * Creates a new Promise. + * @param executor A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; + all(values: Iterable>): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: Iterable>): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; + + readonly [Symbol.species]: Function; +} + +declare var Promise: PromiseConstructor; +interface Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: T, fromIndex?: number): boolean; +} + +interface Int8Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint8ClampedArray { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int16Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint16Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Int32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Uint32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float32Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +} + +interface Float64Array { + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: number, fromIndex?: number): boolean; +}///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare const NaN: number; +declare const Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +interface Object { + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; + + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +interface ObjectConstructor { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + readonly prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: T): T; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: T): T; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: T): T; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare const Object: ObjectConstructor; + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + readonly length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +interface FunctionConstructor { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + readonly prototype: Function; +} + +declare const Function: FunctionConstructor; + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): RegExpMatchArray; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): RegExpMatchArray; + + /** + * Replaces text in a string, using a regular expression or search string. + * @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 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 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 replacer A function that returns the replacement text. + */ + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + readonly length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): string; + + readonly [index: number]: string; +} + +interface StringConstructor { + new (value?: any): String; + (value?: any): string; + readonly prototype: String; + fromCharCode(...codes: number[]): string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare const String: StringConstructor; + +interface Boolean { + /** Returns the primitive value of the specified object. */ + valueOf(): boolean; +} + +interface BooleanConstructor { + new (value?: any): Boolean; + (value?: any): boolean; + readonly prototype: Boolean; +} + +declare const Boolean: BooleanConstructor; + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): number; +} + +interface NumberConstructor { + new (value?: any): Number; + (value?: any): number; + readonly prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + readonly MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + readonly MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + readonly NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + readonly NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + readonly POSITIVE_INFINITY: number; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare const Number: NumberConstructor; + +interface TemplateStringsArray extends Array { + readonly raw: string[]; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + readonly E: number; + /** The natural logarithm of 10. */ + readonly LN10: number; + /** The natural logarithm of 2. */ + readonly LN2: number; + /** The base-2 logarithm of e. */ + readonly LOG2E: number; + /** The base-10 logarithm of e. */ + readonly LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + readonly PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + readonly SQRT1_2: number; + /** The square root of 2. */ + readonly SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point. + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare const Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; + /** Returns a date as a string value in ISO format. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +interface DateConstructor { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + readonly prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +declare const Date: DateConstructor; + +interface RegExpMatchArray extends Array { + index?: number; + input?: string; +} + +interface RegExpExecArray extends Array { + index: number; + input: string; +} + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; + + /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ + readonly source: string; + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + readonly global: boolean; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + readonly ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + readonly multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} + +interface RegExpConstructor { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + readonly prototype: RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +declare const RegExp: RegExpConstructor; + +interface Error { + name: string; + message: string; +} + +interface ErrorConstructor { + new (message?: string): Error; + (message?: string): Error; + readonly prototype: Error; +} + +declare const Error: ErrorConstructor; + +interface EvalError extends Error { +} + +interface EvalErrorConstructor { + new (message?: string): EvalError; + (message?: string): EvalError; + readonly prototype: EvalError; +} + +declare const EvalError: EvalErrorConstructor; + +interface RangeError extends Error { +} + +interface RangeErrorConstructor { + new (message?: string): RangeError; + (message?: string): RangeError; + readonly prototype: RangeError; +} + +declare const RangeError: RangeErrorConstructor; + +interface ReferenceError extends Error { +} + +interface ReferenceErrorConstructor { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + readonly prototype: ReferenceError; +} + +declare const ReferenceError: ReferenceErrorConstructor; + +interface SyntaxError extends Error { +} + +interface SyntaxErrorConstructor { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + readonly prototype: SyntaxError; +} + +declare const SyntaxError: SyntaxErrorConstructor; + +interface TypeError extends Error { +} + +interface TypeErrorConstructor { + new (message?: string): TypeError; + (message?: string): TypeError; + readonly prototype: TypeError; +} + +declare const TypeError: TypeErrorConstructor; + +interface URIError extends Error { +} + +interface URIErrorConstructor { + new (message?: string): URIError; + (message?: string): URIError; + readonly prototype: URIError; +} + +declare const URIError: URIErrorConstructor; + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): 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 A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): 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. + */ + stringify(value: any, replacer: any[]): 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 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: 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: string | number): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare const JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface ReadonlyArray { + /** + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ + readonly length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat>(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * 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 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): T[]; + /** + * 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: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; + /** + * 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: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + /** + * 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: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => 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: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + + readonly [n: number]: T; +} + +interface Array { + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: (T | T[])[]): T[]; + /** + * 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; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * 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): T[]; + /** + * 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: T, b: T) => number): T[]; + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + /** + * 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: T, fromIndex?: number): number; + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + /** + * 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: T, index: number, array: T[]) => void, thisArg?: any): void; + /** + * 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: T, index: number, array: T[]) => U, thisArg?: any): U[]; + /** + * 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: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: T[]) => 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: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to 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: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + [n: number]: T; +} + +interface ArrayConstructor { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): arg is Array; + readonly prototype: Array; +} + +declare const Array: ArrayConstructor; + +interface TypedPropertyDescriptor { + enumerable?: boolean; + configurable?: boolean; + writable?: boolean; + value?: T; + get?: () => T; + set?: (value: T) => void; +} + +declare type ClassDecorator = (target: TFunction) => TFunction | void; +declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; +declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; +declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} + +interface ArrayLike { + readonly length: number; + readonly [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). + */ + readonly byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + readonly prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): arg is ArrayBufferView; +} +declare const 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 { + readonly buffer: ArrayBuffer; + readonly byteLength: number; + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const 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. + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + readonly buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + readonly byteLength: number; + + /** + * The offset in bytes of the array. + */ + readonly 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. + */ + readonly 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 { + readonly 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. + */ + readonly 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 const Float64Array: Float64ArrayConstructor; +///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// + +declare module Intl { + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + minimumIntegerDigits?: number; + minimumFractionDigits?: number; + maximumFractionDigits?: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumIntegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): NumberFormat; + new (locale?: string, options?: NumberFormatOptions): NumberFormat; + (locales?: string[], options?: NumberFormatOptions): NumberFormat; + (locale?: string, options?: NumberFormatOptions): NumberFormat; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12?: boolean; + timeZone?: string; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date?: Date | number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat; + new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat; + (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat; + (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @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. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Number { + /** + * Converts a number 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.NumberFormatOptions): string; + + /** + * Converts a number 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.NumberFormatOptions): string; +} + +interface Date { + /** + * 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. + */ + 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; +} + + +///////////////////////////// +/// IE DOM APIs +///////////////////////////// + +interface Algorithm { + name?: string; +} + +interface AriaRequestEventInit extends EventInit { + attributeName?: string; + attributeValue?: string; +} + +interface ClipboardEventInit extends EventInit { + data?: string; + dataType?: string; +} + +interface CommandEventInit extends EventInit { + commandName?: string; + detail?: string; +} + +interface CompositionEventInit extends UIEventInit { + data?: string; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: string[]; +} + +interface CustomEventInit extends EventInit { + detail?: any; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; +} + +interface ExceptionInformation { + domain?: string; +} + +interface FocusEventInit extends UIEventInit { + relatedTarget?: EventTarget; +} + +interface HashChangeEventInit extends EventInit { + newURL?: string; + oldURL?: string; +} + +interface KeyAlgorithm { + name?: string; +} + +interface KeyboardEventInit extends SharedKeyboardAndMouseEventInit { + key?: string; + location?: number; + repeat?: boolean; +} + +interface MouseEventInit extends SharedKeyboardAndMouseEventInit { + screenX?: number; + screenY?: number; + clientX?: number; + clientY?: number; + button?: number; + buttons?: number; + relatedTarget?: EventTarget; +} + +interface MsZoomToOptions { + contentX?: number; + contentY?: number; + viewportX?: string; + viewportY?: string; + scaleFactor?: number; + animate?: string; +} + +interface MutationObserverInit { + childList?: boolean; + attributes?: boolean; + characterData?: boolean; + subtree?: boolean; + attributeOldValue?: boolean; + characterDataOldValue?: boolean; + attributeFilter?: string[]; +} + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface PointerEventInit extends MouseEventInit { + pointerId?: number; + width?: number; + height?: number; + pressure?: number; + tiltX?: number; + tiltY?: number; + pointerType?: string; + isPrimary?: boolean; +} + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface SharedKeyboardAndMouseEventInit extends UIEventInit { + ctrlKey?: boolean; + shiftKey?: boolean; + altKey?: boolean; + metaKey?: boolean; + keyModifierStateAltGraph?: boolean; + keyModifierStateCapsLock?: boolean; + keyModifierStateFn?: boolean; + keyModifierStateFnLock?: boolean; + keyModifierStateHyper?: boolean; + keyModifierStateNumLock?: boolean; + keyModifierStateOS?: boolean; + keyModifierStateScrollLock?: boolean; + keyModifierStateSuper?: boolean; + keyModifierStateSymbol?: boolean; + keyModifierStateSymbolLock?: boolean; +} + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: string[]; +} + +interface UIEventInit extends EventInit { + view?: Window; + detail?: number; +} + +interface WebGLContextAttributes { + alpha?: boolean; + depth?: boolean; + stencil?: boolean; + antialias?: boolean; + premultipliedAlpha?: boolean; + preserveDrawingBuffer?: boolean; +} + +interface WebGLContextEventInit extends EventInit { + statusMessage?: string; +} + +interface WheelEventInit extends MouseEventInit { + deltaX?: number; + deltaY?: number; + deltaZ?: number; + deltaMode?: number; +} + +interface EventListener { + (evt: Event): void; +} + +interface ANGLE_instanced_arrays { + drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; + drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; + vertexAttribDivisorANGLE(index: number, divisor: number): void; + VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +declare var ANGLE_instanced_arrays: { + prototype: ANGLE_instanced_arrays; + new(): ANGLE_instanced_arrays; + VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +interface AnalyserNode extends AudioNode { + fftSize: number; + frequencyBinCount: number; + maxDecibels: number; + minDecibels: number; + smoothingTimeConstant: number; + getByteFrequencyData(array: Uint8Array): void; + getByteTimeDomainData(array: Uint8Array): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; +} + +declare var AnalyserNode: { + prototype: AnalyserNode; + new(): AnalyserNode; +} + +interface AnimationEvent extends Event { + animationName: string; + elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} + +declare var AnimationEvent: { + prototype: AnimationEvent; + new(): AnimationEvent; +} + +interface ApplicationCache extends EventTarget { + oncached: (ev: Event) => any; + onchecking: (ev: Event) => any; + ondownloading: (ev: Event) => any; + onerror: (ev: Event) => any; + onnoupdate: (ev: Event) => any; + onobsolete: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + onupdateready: (ev: Event) => any; + status: number; + abort(): void; + swapCache(): void; + update(): void; + CHECKING: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; + UNCACHED: number; + UPDATEREADY: number; + addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "obsolete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "updateready", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ApplicationCache: { + prototype: ApplicationCache; + new(): ApplicationCache; + CHECKING: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; + UNCACHED: number; + UPDATEREADY: number; +} + +interface AriaRequestEvent extends Event { + attributeName: string; + attributeValue: string; +} + +declare var AriaRequestEvent: { + prototype: AriaRequestEvent; + new(type: string, eventInitDict?: AriaRequestEventInit): AriaRequestEvent; +} + +interface Attr extends Node { + name: string; + ownerElement: Element; + specified: boolean; + value: string; +} + +declare var Attr: { + prototype: Attr; + new(): Attr; +} + +interface AudioBuffer { + duration: number; + length: number; + numberOfChannels: number; + sampleRate: number; + getChannelData(channel: number): Float32Array; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + +interface AudioBufferSourceNode extends AudioNode { + buffer: AudioBuffer; + loop: boolean; + loopEnd: number; + loopStart: number; + onended: (ev: Event) => any; + playbackRate: AudioParam; + start(when?: number, offset?: number, duration?: number): void; + stop(when?: number): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var AudioBufferSourceNode: { + prototype: AudioBufferSourceNode; + new(): AudioBufferSourceNode; +} + +interface AudioContext extends EventTarget { + currentTime: number; + destination: AudioDestinationNode; + listener: AudioListener; + sampleRate: number; + state: string; + createAnalyser(): AnalyserNode; + createBiquadFilter(): BiquadFilterNode; + createBuffer(numberOfChannels: number, length: number, sampleRate: number): AudioBuffer; + createBufferSource(): AudioBufferSourceNode; + createChannelMerger(numberOfInputs?: number): ChannelMergerNode; + createChannelSplitter(numberOfOutputs?: number): ChannelSplitterNode; + createConvolver(): ConvolverNode; + createDelay(maxDelayTime?: number): DelayNode; + createDynamicsCompressor(): DynamicsCompressorNode; + createGain(): GainNode; + createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; + createOscillator(): OscillatorNode; + createPanner(): PannerNode; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; + createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; + createStereoPanner(): StereoPannerNode; + createWaveShaper(): WaveShaperNode; + decodeAudioData(audioData: ArrayBuffer, successCallback: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): void; +} + +declare var AudioContext: { + prototype: AudioContext; + new(): AudioContext; +} + +interface AudioDestinationNode extends AudioNode { + maxChannelCount: number; +} + +declare var AudioDestinationNode: { + prototype: AudioDestinationNode; + new(): AudioDestinationNode; +} + +interface AudioListener { + dopplerFactor: number; + speedOfSound: number; + setOrientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): void; + setPosition(x: number, y: number, z: number): void; + setVelocity(x: number, y: number, z: number): void; +} + +declare var AudioListener: { + prototype: AudioListener; + new(): AudioListener; +} + +interface AudioNode extends EventTarget { + channelCount: number; + channelCountMode: string; + channelInterpretation: string; + context: AudioContext; + numberOfInputs: number; + numberOfOutputs: number; + connect(destination: AudioNode, output?: number, input?: number): void; + disconnect(output?: number): void; + disconnect(destination: AudioNode, output?: number, input?: number): void; + disconnect(destination: AudioParam, output?: number): void; +} + +declare var AudioNode: { + prototype: AudioNode; + new(): AudioNode; +} + +interface AudioParam { + defaultValue: number; + value: number; + cancelScheduledValues(startTime: number): void; + exponentialRampToValueAtTime(value: number, endTime: number): void; + linearRampToValueAtTime(value: number, endTime: number): void; + setTargetAtTime(target: number, startTime: number, timeConstant: number): void; + setValueAtTime(value: number, startTime: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; +} + +declare var AudioParam: { + prototype: AudioParam; + new(): AudioParam; +} + +interface AudioProcessingEvent extends Event { + inputBuffer: AudioBuffer; + outputBuffer: AudioBuffer; + playbackTime: number; +} + +declare var AudioProcessingEvent: { + prototype: AudioProcessingEvent; + new(): AudioProcessingEvent; +} + +interface AudioTrack { + enabled: boolean; + id: string; + kind: string; + label: string; + language: string; + sourceBuffer: SourceBuffer; +} + +declare var AudioTrack: { + prototype: AudioTrack; + new(): AudioTrack; +} + +interface AudioTrackList extends EventTarget { + length: number; + onaddtrack: (ev: TrackEvent) => any; + onchange: (ev: Event) => any; + onremovetrack: (ev: TrackEvent) => any; + getTrackById(id: string): AudioTrack; + item(index: number): AudioTrack; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: AudioTrack; +} + +declare var AudioTrackList: { + prototype: AudioTrackList; + new(): AudioTrackList; +} + +interface BarProp { + visible: boolean; +} + +declare var BarProp: { + prototype: BarProp; + new(): BarProp; +} + +interface BeforeUnloadEvent extends Event { + returnValue: any; +} + +declare var BeforeUnloadEvent: { + prototype: BeforeUnloadEvent; + new(): BeforeUnloadEvent; +} + +interface BiquadFilterNode extends AudioNode { + Q: AudioParam; + detune: AudioParam; + frequency: AudioParam; + gain: AudioParam; + type: string; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var BiquadFilterNode: { + prototype: BiquadFilterNode; + new(): BiquadFilterNode; +} + +interface Blob { + size: number; + type: string; + msClose(): void; + msDetachStream(): any; + slice(start?: number, end?: number, contentType?: string): Blob; +} + +declare var Blob: { + prototype: Blob; + new (blobParts?: any[], options?: BlobPropertyBag): Blob; +} + +interface CDATASection extends Text { +} + +declare var CDATASection: { + prototype: CDATASection; + new(): CDATASection; +} + +interface CSS { + supports(property: string, value?: string): boolean; +} +declare var CSS: CSS; + +interface CSSConditionRule extends CSSGroupingRule { + conditionText: string; +} + +declare var CSSConditionRule: { + prototype: CSSConditionRule; + new(): CSSConditionRule; +} + +interface CSSFontFaceRule extends CSSRule { + style: CSSStyleDeclaration; +} + +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new(): CSSFontFaceRule; +} + +interface CSSGroupingRule extends CSSRule { + cssRules: CSSRuleList; + deleteRule(index?: number): void; + insertRule(rule: string, index?: number): number; +} + +declare var CSSGroupingRule: { + prototype: CSSGroupingRule; + new(): CSSGroupingRule; +} + +interface CSSImportRule extends CSSRule { + href: string; + media: MediaList; + styleSheet: CSSStyleSheet; +} + +declare var CSSImportRule: { + prototype: CSSImportRule; + new(): CSSImportRule; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + style: CSSStyleDeclaration; +} + +declare var CSSKeyframeRule: { + prototype: CSSKeyframeRule; + new(): CSSKeyframeRule; +} + +interface CSSKeyframesRule extends CSSRule { + cssRules: CSSRuleList; + name: string; + appendRule(rule: string): void; + deleteRule(rule: string): void; + findRule(rule: string): CSSKeyframeRule; +} + +declare var CSSKeyframesRule: { + prototype: CSSKeyframesRule; + new(): CSSKeyframesRule; +} + +interface CSSMediaRule extends CSSConditionRule { + media: MediaList; +} + +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new(): CSSMediaRule; +} + +interface CSSNamespaceRule extends CSSRule { + namespaceURI: string; + prefix: string; +} + +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new(): CSSNamespaceRule; +} + +interface CSSPageRule extends CSSRule { + pseudoClass: string; + selector: string; + selectorText: string; + style: CSSStyleDeclaration; +} + +declare var CSSPageRule: { + prototype: CSSPageRule; + new(): CSSPageRule; +} + +interface CSSRule { + cssText: string; + parentRule: CSSRule; + parentStyleSheet: CSSStyleSheet; + type: number; + CHARSET_RULE: number; + FONT_FACE_RULE: number; + IMPORT_RULE: number; + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + MEDIA_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + STYLE_RULE: number; + SUPPORTS_RULE: number; + UNKNOWN_RULE: number; + VIEWPORT_RULE: number; +} + +declare var CSSRule: { + prototype: CSSRule; + new(): CSSRule; + CHARSET_RULE: number; + FONT_FACE_RULE: number; + IMPORT_RULE: number; + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + MEDIA_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + STYLE_RULE: number; + SUPPORTS_RULE: number; + UNKNOWN_RULE: number; + VIEWPORT_RULE: number; +} + +interface CSSRuleList { + length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} + +declare var CSSRuleList: { + prototype: CSSRuleList; + new(): CSSRuleList; +} + +interface CSSStyleDeclaration { + alignContent: string; + alignItems: string; + alignSelf: string; + alignmentBaseline: string; + animation: string; + animationDelay: string; + animationDirection: string; + animationDuration: string; + animationFillMode: string; + animationIterationCount: string; + animationName: string; + animationPlayState: string; + animationTimingFunction: string; + backfaceVisibility: string; + background: string; + backgroundAttachment: string; + backgroundClip: string; + backgroundColor: string; + backgroundImage: string; + backgroundOrigin: string; + backgroundPosition: string; + backgroundPositionX: string; + backgroundPositionY: string; + backgroundRepeat: string; + backgroundSize: string; + baselineShift: string; + border: string; + borderBottom: string; + borderBottomColor: string; + borderBottomLeftRadius: string; + borderBottomRightRadius: string; + borderBottomStyle: string; + borderBottomWidth: string; + borderCollapse: string; + borderColor: string; + borderImage: string; + borderImageOutset: string; + borderImageRepeat: string; + borderImageSlice: string; + borderImageSource: string; + borderImageWidth: string; + borderLeft: string; + borderLeftColor: string; + borderLeftStyle: string; + borderLeftWidth: string; + borderRadius: string; + borderRight: string; + borderRightColor: string; + borderRightStyle: string; + borderRightWidth: string; + borderSpacing: string; + borderStyle: string; + borderTop: string; + borderTopColor: string; + borderTopLeftRadius: string; + borderTopRightRadius: string; + borderTopStyle: string; + borderTopWidth: string; + borderWidth: string; + bottom: string; + boxShadow: string; + boxSizing: string; + breakAfter: string; + breakBefore: string; + breakInside: string; + captionSide: string; + clear: string; + clip: string; + clipPath: string; + clipRule: string; + color: string; + colorInterpolationFilters: string; + columnCount: any; + columnFill: string; + columnGap: any; + columnRule: string; + columnRuleColor: any; + columnRuleStyle: string; + columnRuleWidth: any; + columnSpan: string; + columnWidth: any; + columns: string; + content: string; + counterIncrement: string; + counterReset: string; + cssFloat: string; + cssText: string; + cursor: string; + direction: string; + display: string; + dominantBaseline: string; + emptyCells: string; + enableBackground: string; + fill: string; + fillOpacity: string; + fillRule: string; + filter: string; + flex: string; + flexBasis: string; + flexDirection: string; + flexFlow: string; + flexGrow: string; + flexShrink: string; + flexWrap: string; + floodColor: string; + floodOpacity: string; + font: string; + fontFamily: string; + fontFeatureSettings: string; + fontSize: string; + fontSizeAdjust: string; + fontStretch: string; + fontStyle: string; + fontVariant: string; + fontWeight: string; + glyphOrientationHorizontal: string; + glyphOrientationVertical: string; + height: string; + imeMode: string; + justifyContent: string; + kerning: string; + left: string; + length: number; + letterSpacing: string; + lightingColor: string; + lineHeight: string; + listStyle: string; + listStyleImage: string; + listStylePosition: string; + listStyleType: string; + margin: string; + marginBottom: string; + marginLeft: string; + marginRight: string; + marginTop: string; + marker: string; + markerEnd: string; + markerMid: string; + markerStart: string; + mask: string; + maxHeight: string; + maxWidth: string; + minHeight: string; + minWidth: string; + msContentZoomChaining: string; + msContentZoomLimit: string; + msContentZoomLimitMax: any; + msContentZoomLimitMin: any; + msContentZoomSnap: string; + msContentZoomSnapPoints: string; + msContentZoomSnapType: string; + msContentZooming: string; + msFlowFrom: string; + msFlowInto: string; + msFontFeatureSettings: string; + msGridColumn: any; + msGridColumnAlign: string; + msGridColumnSpan: any; + msGridColumns: string; + msGridRow: any; + msGridRowAlign: string; + msGridRowSpan: any; + msGridRows: string; + msHighContrastAdjust: string; + msHyphenateLimitChars: string; + msHyphenateLimitLines: any; + msHyphenateLimitZone: any; + msHyphens: string; + msImeAlign: string; + msOverflowStyle: string; + msScrollChaining: string; + msScrollLimit: string; + msScrollLimitXMax: any; + msScrollLimitXMin: any; + msScrollLimitYMax: any; + msScrollLimitYMin: any; + msScrollRails: string; + msScrollSnapPointsX: string; + msScrollSnapPointsY: string; + msScrollSnapType: string; + msScrollSnapX: string; + msScrollSnapY: string; + msScrollTranslation: string; + msTextCombineHorizontal: string; + msTextSizeAdjust: any; + msTouchAction: string; + msTouchSelect: string; + msUserSelect: string; + msWrapFlow: string; + msWrapMargin: any; + msWrapThrough: string; + opacity: string; + order: string; + orphans: string; + outline: string; + outlineColor: string; + outlineStyle: string; + outlineWidth: string; + overflow: string; + overflowX: string; + overflowY: string; + padding: string; + paddingBottom: string; + paddingLeft: string; + paddingRight: string; + paddingTop: string; + pageBreakAfter: string; + pageBreakBefore: string; + pageBreakInside: string; + parentRule: CSSRule; + perspective: string; + perspectiveOrigin: string; + pointerEvents: string; + position: string; + quotes: string; + right: string; + rubyAlign: string; + rubyOverhang: string; + rubyPosition: string; + stopColor: string; + stopOpacity: string; + stroke: string; + strokeDasharray: string; + strokeDashoffset: string; + strokeLinecap: string; + strokeLinejoin: string; + strokeMiterlimit: string; + strokeOpacity: string; + strokeWidth: string; + tableLayout: string; + textAlign: string; + textAlignLast: string; + textAnchor: string; + textDecoration: string; + textFillColor: string; + textIndent: string; + textJustify: string; + textKashida: string; + textKashidaSpace: string; + textOverflow: string; + textShadow: string; + textTransform: string; + textUnderlinePosition: string; + top: string; + touchAction: string; + transform: string; + transformOrigin: string; + transformStyle: string; + transition: string; + transitionDelay: string; + transitionDuration: string; + transitionProperty: string; + transitionTimingFunction: string; + unicodeBidi: string; + verticalAlign: string; + visibility: string; + webkitAlignContent: string; + webkitAlignItems: string; + webkitAlignSelf: string; + webkitAnimation: string; + webkitAnimationDelay: string; + webkitAnimationDirection: string; + webkitAnimationDuration: string; + webkitAnimationFillMode: string; + webkitAnimationIterationCount: string; + webkitAnimationName: string; + webkitAnimationPlayState: string; + webkitAnimationTimingFunction: string; + webkitAppearance: string; + webkitBackfaceVisibility: string; + webkitBackground: string; + webkitBackgroundAttachment: string; + webkitBackgroundClip: string; + webkitBackgroundColor: string; + webkitBackgroundImage: string; + webkitBackgroundOrigin: string; + webkitBackgroundPosition: string; + webkitBackgroundPositionX: string; + webkitBackgroundPositionY: string; + webkitBackgroundRepeat: string; + webkitBackgroundSize: string; + webkitBorderBottomLeftRadius: string; + webkitBorderBottomRightRadius: string; + webkitBorderImage: string; + webkitBorderImageOutset: string; + webkitBorderImageRepeat: string; + webkitBorderImageSlice: string; + webkitBorderImageSource: string; + webkitBorderImageWidth: string; + webkitBorderRadius: string; + webkitBorderTopLeftRadius: string; + webkitBorderTopRightRadius: string; + webkitBoxAlign: string; + webkitBoxDirection: string; + webkitBoxFlex: string; + webkitBoxOrdinalGroup: string; + webkitBoxOrient: string; + webkitBoxPack: string; + webkitBoxSizing: string; + webkitColumnBreakAfter: string; + webkitColumnBreakBefore: string; + webkitColumnBreakInside: string; + webkitColumnCount: any; + webkitColumnGap: any; + webkitColumnRule: string; + webkitColumnRuleColor: any; + webkitColumnRuleStyle: string; + webkitColumnRuleWidth: any; + webkitColumnSpan: string; + webkitColumnWidth: any; + webkitColumns: string; + webkitFilter: string; + webkitFlex: string; + webkitFlexBasis: string; + webkitFlexDirection: string; + webkitFlexFlow: string; + webkitFlexGrow: string; + webkitFlexShrink: string; + webkitFlexWrap: string; + webkitJustifyContent: string; + webkitOrder: string; + webkitPerspective: string; + webkitPerspectiveOrigin: string; + webkitTapHighlightColor: string; + webkitTextFillColor: string; + webkitTextSizeAdjust: any; + webkitTransform: string; + webkitTransformOrigin: string; + webkitTransformStyle: string; + webkitTransition: string; + webkitTransitionDelay: string; + webkitTransitionDuration: string; + webkitTransitionProperty: string; + webkitTransitionTimingFunction: string; + webkitUserSelect: string; + webkitWritingMode: string; + whiteSpace: string; + widows: string; + width: string; + wordBreak: string; + wordSpacing: string; + wordWrap: string; + writingMode: string; + zIndex: string; + zoom: string; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + item(index: number): string; + removeProperty(propertyName: string): string; + setProperty(propertyName: string, value: string, priority?: string): void; + [index: number]: string; +} + +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new(): CSSStyleDeclaration; +} + +interface CSSStyleRule extends CSSRule { + readOnly: boolean; + selectorText: string; + style: CSSStyleDeclaration; +} + +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new(): CSSStyleRule; +} + +interface CSSStyleSheet extends StyleSheet { + cssRules: CSSRuleList; + cssText: string; + href: string; + id: string; + imports: StyleSheetList; + isAlternate: boolean; + isPrefAlternate: boolean; + ownerRule: CSSRule; + owningElement: Element; + pages: StyleSheetPageList; + readOnly: boolean; + rules: CSSRuleList; + addImport(bstrURL: string, lIndex?: number): number; + addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; + addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; + deleteRule(index?: number): void; + insertRule(rule: string, index?: number): number; + removeImport(lIndex: number): void; + removeRule(lIndex: number): void; +} + +declare var CSSStyleSheet: { + prototype: CSSStyleSheet; + new(): CSSStyleSheet; +} + +interface CSSSupportsRule extends CSSConditionRule { +} + +declare var CSSSupportsRule: { + prototype: CSSSupportsRule; + new(): CSSSupportsRule; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} + +declare var CanvasGradient: { + prototype: CanvasGradient; + new(): CanvasGradient; +} + +interface CanvasPattern { +} + +declare var CanvasPattern: { + prototype: CanvasPattern; + new(): CanvasPattern; +} + +interface CanvasRenderingContext2D { + canvas: HTMLCanvasElement; + fillStyle: string | CanvasGradient | CanvasPattern; + font: string; + globalAlpha: number; + globalCompositeOperation: string; + lineCap: string; + lineDashOffset: number; + lineJoin: string; + lineWidth: number; + miterLimit: number; + msFillRule: string; + msImageSmoothingEnabled: boolean; + shadowBlur: number; + shadowColor: string; + shadowOffsetX: number; + shadowOffsetY: number; + strokeStyle: string | CanvasGradient | CanvasPattern; + textAlign: string; + textBaseline: string; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + beginPath(): void; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + clearRect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: string): void; + closePath(): void; + createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; + createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + fill(fillRule?: string): void; + fillRect(x: number, y: number, w: number, h: number): void; + fillText(text: string, x: number, y: number, maxWidth?: number): void; + getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + getLineDash(): number[]; + isPointInPath(x: number, y: number, fillRule?: string): boolean; + lineTo(x: number, y: number): void; + measureText(text: string): TextMetrics; + moveTo(x: number, y: number): void; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + rect(x: number, y: number, w: number, h: number): void; + restore(): void; + rotate(angle: number): void; + save(): void; + scale(x: number, y: number): void; + setLineDash(segments: number[]): void; + setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + stroke(): void; + strokeRect(x: number, y: number, w: number, h: number): void; + strokeText(text: string, x: number, y: number, maxWidth?: number): void; + transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + translate(x: number, y: number): void; +} + +declare var CanvasRenderingContext2D: { + prototype: CanvasRenderingContext2D; + new(): CanvasRenderingContext2D; +} + +interface ChannelMergerNode extends AudioNode { +} + +declare var ChannelMergerNode: { + prototype: ChannelMergerNode; + new(): ChannelMergerNode; +} + +interface ChannelSplitterNode extends AudioNode { +} + +declare var ChannelSplitterNode: { + prototype: ChannelSplitterNode; + new(): ChannelSplitterNode; +} + +interface CharacterData extends Node, ChildNode { + data: string; + length: number; + appendData(arg: string): void; + deleteData(offset: number, count: number): void; + insertData(offset: number, arg: string): void; + replaceData(offset: number, count: number, arg: string): void; + substringData(offset: number, count: number): string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var CharacterData: { + prototype: CharacterData; + new(): CharacterData; +} + +interface ClientRect { + bottom: number; + height: number; + left: number; + right: number; + top: number; + width: number; +} + +declare var ClientRect: { + prototype: ClientRect; + new(): ClientRect; +} + +interface ClientRectList { + length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} + +declare var ClientRectList: { + prototype: ClientRectList; + new(): ClientRectList; +} + +interface ClipboardEvent extends Event { + clipboardData: DataTransfer; +} + +declare var ClipboardEvent: { + prototype: ClipboardEvent; + new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent; +} + +interface CloseEvent extends Event { + code: number; + reason: string; + wasClean: boolean; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} + +declare var CloseEvent: { + prototype: CloseEvent; + new(): CloseEvent; +} + +interface CommandEvent extends Event { + commandName: string; + detail: string; +} + +declare var CommandEvent: { + prototype: CommandEvent; + new(type: string, eventInitDict?: CommandEventInit): CommandEvent; +} + +interface Comment extends CharacterData { + text: string; +} + +declare var Comment: { + prototype: Comment; + new(): Comment; +} + +interface CompositionEvent extends UIEvent { + data: string; + locale: string; + initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; +} + +declare var CompositionEvent: { + prototype: CompositionEvent; + new(typeArg: string, eventInitDict?: CompositionEventInit): CompositionEvent; +} + +interface Console { + assert(test?: boolean, message?: string, ...optionalParams: any[]): void; + clear(): void; + count(countTitle?: string): void; + debug(message?: string, ...optionalParams: any[]): void; + dir(value?: any, ...optionalParams: any[]): void; + dirxml(value: any): void; + error(message?: any, ...optionalParams: any[]): void; + group(groupTitle?: string): void; + groupCollapsed(groupTitle?: string): void; + groupEnd(): void; + info(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + msIsIndependentlyComposed(element: Element): boolean; + profile(reportName?: string): void; + profileEnd(): void; + select(element: Element): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(message?: any, ...optionalParams: any[]): void; + warn(message?: any, ...optionalParams: any[]): void; +} + +declare var Console: { + prototype: Console; + new(): Console; +} + +interface ConvolverNode extends AudioNode { + buffer: AudioBuffer; + normalize: boolean; +} + +declare var ConvolverNode: { + prototype: ConvolverNode; + new(): ConvolverNode; +} + +interface Coordinates { + accuracy: number; + altitude: number; + altitudeAccuracy: number; + heading: number; + latitude: number; + longitude: number; + speed: number; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + +interface Crypto extends Object, RandomSource { + subtle: SubtleCrypto; +} + +declare var Crypto: { + prototype: Crypto; + new(): Crypto; +} + +interface CryptoKey { + algorithm: KeyAlgorithm; + extractable: boolean; + type: string; + usages: string[]; +} + +declare var CryptoKey: { + prototype: CryptoKey; + new(): CryptoKey; +} + +interface CryptoKeyPair { + privateKey: CryptoKey; + publicKey: CryptoKey; +} + +declare var CryptoKeyPair: { + prototype: CryptoKeyPair; + new(): CryptoKeyPair; +} + +interface CustomEvent extends Event { + detail: any; + initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; +} + +declare var CustomEvent: { + prototype: CustomEvent; + new(typeArg: string, eventInitDict?: CustomEventInit): CustomEvent; +} + +interface DOMError { + name: string; + toString(): string; +} + +declare var DOMError: { + prototype: DOMError; + new(): DOMError; +} + +interface DOMException { + code: number; + message: string; + name: string; + toString(): string; + ABORT_ERR: number; + DATA_CLONE_ERR: number; + DOMSTRING_SIZE_ERR: number; + HIERARCHY_REQUEST_ERR: number; + INDEX_SIZE_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_ACCESS_ERR: number; + INVALID_CHARACTER_ERR: number; + INVALID_MODIFICATION_ERR: number; + INVALID_NODE_TYPE_ERR: number; + INVALID_STATE_ERR: number; + NAMESPACE_ERR: number; + NETWORK_ERR: number; + NOT_FOUND_ERR: number; + NOT_SUPPORTED_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + PARSE_ERR: number; + QUOTA_EXCEEDED_ERR: number; + SECURITY_ERR: number; + SERIALIZE_ERR: number; + SYNTAX_ERR: number; + TIMEOUT_ERR: number; + TYPE_MISMATCH_ERR: number; + URL_MISMATCH_ERR: number; + VALIDATION_ERR: number; + WRONG_DOCUMENT_ERR: number; +} + +declare var DOMException: { + prototype: DOMException; + new(): DOMException; + ABORT_ERR: number; + DATA_CLONE_ERR: number; + DOMSTRING_SIZE_ERR: number; + HIERARCHY_REQUEST_ERR: number; + INDEX_SIZE_ERR: number; + INUSE_ATTRIBUTE_ERR: number; + INVALID_ACCESS_ERR: number; + INVALID_CHARACTER_ERR: number; + INVALID_MODIFICATION_ERR: number; + INVALID_NODE_TYPE_ERR: number; + INVALID_STATE_ERR: number; + NAMESPACE_ERR: number; + NETWORK_ERR: number; + NOT_FOUND_ERR: number; + NOT_SUPPORTED_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + PARSE_ERR: number; + QUOTA_EXCEEDED_ERR: number; + SECURITY_ERR: number; + SERIALIZE_ERR: number; + SYNTAX_ERR: number; + TIMEOUT_ERR: number; + TYPE_MISMATCH_ERR: number; + URL_MISMATCH_ERR: number; + VALIDATION_ERR: number; + WRONG_DOCUMENT_ERR: number; +} + +interface DOMImplementation { + createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createHTMLDocument(title: string): Document; + hasFeature(feature: string, version: string): boolean; +} + +declare var DOMImplementation: { + prototype: DOMImplementation; + new(): DOMImplementation; +} + +interface DOMParser { + parseFromString(source: string, mimeType: string): Document; +} + +declare var DOMParser: { + prototype: DOMParser; + new(): DOMParser; +} + +interface DOMSettableTokenList extends DOMTokenList { + value: string; +} + +declare var DOMSettableTokenList: { + prototype: DOMSettableTokenList; + new(): DOMSettableTokenList; +} + +interface DOMStringList { + length: number; + contains(str: string): boolean; + item(index: number): string; + [index: number]: string; +} + +declare var DOMStringList: { + prototype: DOMStringList; + new(): DOMStringList; +} + +interface DOMStringMap { + [name: string]: string; +} + +declare var DOMStringMap: { + prototype: DOMStringMap; + new(): DOMStringMap; +} + +interface DOMTokenList { + length: number; + add(...token: string[]): void; + contains(token: string): boolean; + item(index: number): string; + remove(...token: string[]): void; + toString(): string; + toggle(token: string, force?: boolean): boolean; + [index: number]: string; +} + +declare var DOMTokenList: { + prototype: DOMTokenList; + new(): DOMTokenList; +} + +interface DataCue extends TextTrackCue { + data: ArrayBuffer; +} + +declare var DataCue: { + prototype: DataCue; + new(): DataCue; +} + +interface DataTransfer { + dropEffect: string; + effectAllowed: string; + files: FileList; + items: DataTransferItemList; + types: DOMStringList; + clearData(format?: string): boolean; + getData(format: string): string; + setData(format: string, data: string): boolean; +} + +declare var DataTransfer: { + prototype: DataTransfer; + new(): DataTransfer; +} + +interface DataTransferItem { + kind: string; + type: string; + getAsFile(): File; + getAsString(_callback: FunctionStringCallback): void; +} + +declare var DataTransferItem: { + prototype: DataTransferItem; + new(): DataTransferItem; +} + +interface DataTransferItemList { + length: number; + add(data: File): DataTransferItem; + clear(): void; + item(index: number): DataTransferItem; + remove(index: number): void; + [index: number]: DataTransferItem; +} + +declare var DataTransferItemList: { + prototype: DataTransferItemList; + new(): DataTransferItemList; +} + +interface DeferredPermissionRequest { + id: number; + type: string; + uri: string; + allow(): void; + deny(): void; +} + +declare var DeferredPermissionRequest: { + prototype: DeferredPermissionRequest; + new(): DeferredPermissionRequest; +} + +interface DelayNode extends AudioNode { + delayTime: AudioParam; +} + +declare var DelayNode: { + prototype: DelayNode; + new(): DelayNode; +} + +interface DeviceAcceleration { + x: number; + y: number; + z: number; +} + +declare var DeviceAcceleration: { + prototype: DeviceAcceleration; + new(): DeviceAcceleration; +} + +interface DeviceMotionEvent extends Event { + acceleration: DeviceAcceleration; + accelerationIncludingGravity: DeviceAcceleration; + interval: number; + rotationRate: DeviceRotationRate; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; +} + +declare var DeviceMotionEvent: { + prototype: DeviceMotionEvent; + new(): DeviceMotionEvent; +} + +interface DeviceOrientationEvent extends Event { + absolute: boolean; + alpha: number; + beta: number; + gamma: number; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; +} + +declare var DeviceOrientationEvent: { + prototype: DeviceOrientationEvent; + new(): DeviceOrientationEvent; +} + +interface DeviceRotationRate { + alpha: number; + beta: number; + gamma: number; +} + +declare var DeviceRotationRate: { + prototype: DeviceRotationRate; + new(): DeviceRotationRate; +} + +interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent { + /** + * Sets or gets the URL for the current document. + */ + URL: string; + /** + * Gets the URL for the document, stripped of any character encoding. + */ + URLUnencoded: string; + /** + * Gets the object that has the focus when the parent document has focus. + */ + activeElement: Element; + /** + * Sets or gets the color of all active links in the document. + */ + alinkColor: string; + /** + * Returns a reference to the collection of elements contained by the object. + */ + all: HTMLCollection; + /** + * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. + */ + anchors: HTMLCollection; + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollection; + /** + * Deprecated. Sets or retrieves a value that indicates the background color behind the object. + */ + bgColor: string; + /** + * Specifies the beginning and end of the document body. + */ + body: HTMLElement; + characterSet: string; + /** + * Gets or sets the character set used to encode the object. + */ + charset: string; + /** + * Gets a value that indicates whether standards-compliant mode is switched on for the object. + */ + compatMode: string; + cookie: string; + /** + * Gets the default character set from the current regional language settings. + */ + defaultCharset: string; + defaultView: Window; + /** + * Sets or gets a value that indicates whether the document can be edited. + */ + designMode: string; + /** + * Sets or retrieves a value that indicates the reading order of the object. + */ + dir: string; + /** + * Gets an object representing the document type declaration associated with the current document. + */ + doctype: DocumentType; + /** + * Gets a reference to the root node of the document. + */ + documentElement: HTMLElement; + /** + * Sets or gets the security domain of the document. + */ + domain: string; + /** + * Retrieves a collection of all embed objects in the document. + */ + embeds: HTMLCollection; + /** + * Sets or gets the foreground (text) color of the document. + */ + fgColor: string; + /** + * Retrieves a collection, in source order, of all form objects in the document. + */ + forms: HTMLCollection; + fullscreenElement: Element; + fullscreenEnabled: boolean; + head: HTMLHeadElement; + hidden: boolean; + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollection; + /** + * Gets the implementation object of the current document. + */ + implementation: DOMImplementation; + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + inputEncoding: string; + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + lastModified: string; + /** + * Sets or gets the color of the document links. + */ + linkColor: string; + /** + * Retrieves a collection of all a objects that specify the href property and all area objects in the document. + */ + links: HTMLCollection; + /** + * Contains information about the current URL. + */ + location: Location; + media: string; + msCSSOMElementFloatMetrics: boolean; + msCapsLockWarningOff: boolean; + msHidden: boolean; + msVisibilityState: string; + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (ev: Event) => any; + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (ev: UIEvent) => any; + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (ev: UIEvent) => any; + /** + * Fires immediately before the activeElement is changed from the current object to another object in the parent document. + * @param ev The event. + */ + onbeforedeactivate: (ev: UIEvent) => any; + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (ev: FocusEvent) => any; + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (ev: Event) => any; + oncanplaythrough: (ev: Event) => any; + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (ev: Event) => any; + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (ev: MouseEvent) => any; + /** + * Fires when the user clicks the right mouse button in the client area, opening the context menu. + * @param ev The mouse event. + */ + oncontextmenu: (ev: PointerEvent) => any; + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (ev: MouseEvent) => any; + /** + * Fires when the activeElement is changed from the current object to another object in the parent document. + * @param ev The UI Event + */ + ondeactivate: (ev: UIEvent) => any; + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (ev: DragEvent) => any; + /** + * Fires on the source object when the user releases the mouse at the close of a drag operation. + * @param ev The event. + */ + ondragend: (ev: DragEvent) => any; + /** + * Fires on the target element when the user drags the object to a valid drop target. + * @param ev The drag event. + */ + ondragenter: (ev: DragEvent) => any; + /** + * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. + * @param ev The drag event. + */ + ondragleave: (ev: DragEvent) => any; + /** + * Fires on the target element continuously while the user drags the object over a valid drop target. + * @param ev The event. + */ + ondragover: (ev: DragEvent) => any; + /** + * Fires on the source object when the user starts to drag a text selection or selected object. + * @param ev The event. + */ + ondragstart: (ev: DragEvent) => any; + ondrop: (ev: DragEvent) => any; + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (ev: Event) => any; + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (ev: Event) => any; + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (ev: Event) => any; + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (ev: Event) => any; + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (ev: FocusEvent) => any; + onfullscreenchange: (ev: Event) => any; + onfullscreenerror: (ev: Event) => any; + oninput: (ev: Event) => any; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (ev: KeyboardEvent) => any; + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (ev: KeyboardEvent) => any; + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (ev: Event) => any; + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (ev: Event) => any; + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (ev: Event) => any; + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (ev: Event) => any; + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (ev: MouseEvent) => any; + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (ev: MouseEvent) => any; + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (ev: MouseWheelEvent) => any; + onmscontentzoom: (ev: UIEvent) => any; + onmsgesturechange: (ev: MSGestureEvent) => any; + onmsgesturedoubletap: (ev: MSGestureEvent) => any; + onmsgestureend: (ev: MSGestureEvent) => any; + onmsgesturehold: (ev: MSGestureEvent) => any; + onmsgesturestart: (ev: MSGestureEvent) => any; + onmsgesturetap: (ev: MSGestureEvent) => any; + onmsinertiastart: (ev: MSGestureEvent) => any; + onmsmanipulationstatechanged: (ev: MSManipulationEvent) => any; + onmspointercancel: (ev: MSPointerEvent) => any; + onmspointerdown: (ev: MSPointerEvent) => any; + onmspointerenter: (ev: MSPointerEvent) => any; + onmspointerleave: (ev: MSPointerEvent) => any; + onmspointermove: (ev: MSPointerEvent) => any; + onmspointerout: (ev: MSPointerEvent) => any; + onmspointerover: (ev: MSPointerEvent) => any; + onmspointerup: (ev: MSPointerEvent) => any; + /** + * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. + * @param ev The event. + */ + onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; + /** + * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. + * @param ev The event. + */ + onmsthumbnailclick: (ev: MSSiteModeEvent) => any; + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (ev: Event) => any; + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (ev: Event) => any; + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (ev: Event) => any; + onpointerlockchange: (ev: Event) => any; + onpointerlockerror: (ev: Event) => any; + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (ev: ProgressEvent) => any; + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (ev: Event) => any; + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (ev: ProgressEvent) => any; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (ev: Event) => any; + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (ev: UIEvent) => any; + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (ev: Event) => any; + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (ev: Event) => any; + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (ev: UIEvent) => any; + onselectstart: (ev: Event) => any; + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (ev: Event) => any; + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (ev: Event) => any; + onsubmit: (ev: Event) => any; + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (ev: Event) => any; + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (ev: Event) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + /** + * Occurs when the volume is changed, or playback is muted or unmuted. + * @param ev The event. + */ + onvolumechange: (ev: Event) => any; + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (ev: Event) => any; + onwebkitfullscreenchange: (ev: Event) => any; + onwebkitfullscreenerror: (ev: Event) => any; + plugins: HTMLCollection; + pointerLockElement: Element; + /** + * Retrieves a value that indicates the current state of the object. + */ + readyState: string; + /** + * Gets the URL of the location that referred the user to the current page. + */ + referrer: string; + /** + * Gets the root svg element in the document hierarchy. + */ + rootElement: SVGSVGElement; + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollection; + security: string; + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + styleSheets: StyleSheetList; + /** + * Contains the title of the document. + */ + title: string; + visibilityState: string; + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + webkitCurrentFullScreenElement: Element; + webkitFullscreenElement: Element; + webkitFullscreenEnabled: boolean; + webkitIsFullScreen: boolean; + xmlEncoding: string; + xmlStandalone: boolean; + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string; + currentScript: HTMLScriptElement; + adoptNode(source: Node): Node; + captureEvents(): void; + clear(): void; + /** + * Closes an output stream and forces the sent data to display. + */ + close(): void; + /** + * Creates an attribute object with a specified name. + * @param name String that sets the attribute object's name. + */ + createAttribute(name: string): Attr; + createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; + createCDATASection(data: string): CDATASection; + /** + * Creates a comment object with the specified data. + * @param data Sets the comment object's data. + */ + createComment(data: string): Comment; + /** + * Creates a new document. + */ + createDocumentFragment(): DocumentFragment; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "a"): HTMLAnchorElement; + createElement(tagName: "abbr"): HTMLPhraseElement; + createElement(tagName: "acronym"): HTMLPhraseElement; + createElement(tagName: "address"): HTMLBlockElement; + createElement(tagName: "applet"): HTMLAppletElement; + createElement(tagName: "area"): HTMLAreaElement; + createElement(tagName: "audio"): HTMLAudioElement; + createElement(tagName: "b"): HTMLPhraseElement; + createElement(tagName: "base"): HTMLBaseElement; + createElement(tagName: "basefont"): HTMLBaseFontElement; + createElement(tagName: "bdo"): HTMLPhraseElement; + createElement(tagName: "big"): HTMLPhraseElement; + createElement(tagName: "blockquote"): HTMLBlockElement; + createElement(tagName: "body"): HTMLBodyElement; + createElement(tagName: "br"): HTMLBRElement; + createElement(tagName: "button"): HTMLButtonElement; + createElement(tagName: "canvas"): HTMLCanvasElement; + createElement(tagName: "caption"): HTMLTableCaptionElement; + createElement(tagName: "center"): HTMLBlockElement; + createElement(tagName: "cite"): HTMLPhraseElement; + createElement(tagName: "code"): HTMLPhraseElement; + createElement(tagName: "col"): HTMLTableColElement; + createElement(tagName: "colgroup"): HTMLTableColElement; + createElement(tagName: "datalist"): HTMLDataListElement; + createElement(tagName: "dd"): HTMLDDElement; + createElement(tagName: "del"): HTMLModElement; + createElement(tagName: "dfn"): HTMLPhraseElement; + createElement(tagName: "dir"): HTMLDirectoryElement; + createElement(tagName: "div"): HTMLDivElement; + createElement(tagName: "dl"): HTMLDListElement; + createElement(tagName: "dt"): HTMLDTElement; + createElement(tagName: "em"): HTMLPhraseElement; + createElement(tagName: "embed"): HTMLEmbedElement; + createElement(tagName: "fieldset"): HTMLFieldSetElement; + createElement(tagName: "font"): HTMLFontElement; + createElement(tagName: "form"): HTMLFormElement; + createElement(tagName: "frame"): HTMLFrameElement; + createElement(tagName: "frameset"): HTMLFrameSetElement; + createElement(tagName: "h1"): HTMLHeadingElement; + createElement(tagName: "h2"): HTMLHeadingElement; + createElement(tagName: "h3"): HTMLHeadingElement; + createElement(tagName: "h4"): HTMLHeadingElement; + createElement(tagName: "h5"): HTMLHeadingElement; + createElement(tagName: "h6"): HTMLHeadingElement; + createElement(tagName: "head"): HTMLHeadElement; + createElement(tagName: "hr"): HTMLHRElement; + createElement(tagName: "html"): HTMLHtmlElement; + createElement(tagName: "i"): HTMLPhraseElement; + createElement(tagName: "iframe"): HTMLIFrameElement; + createElement(tagName: "img"): HTMLImageElement; + createElement(tagName: "input"): HTMLInputElement; + createElement(tagName: "ins"): HTMLModElement; + createElement(tagName: "isindex"): HTMLIsIndexElement; + createElement(tagName: "kbd"): HTMLPhraseElement; + createElement(tagName: "keygen"): HTMLBlockElement; + createElement(tagName: "label"): HTMLLabelElement; + createElement(tagName: "legend"): HTMLLegendElement; + createElement(tagName: "li"): HTMLLIElement; + createElement(tagName: "link"): HTMLLinkElement; + createElement(tagName: "listing"): HTMLBlockElement; + createElement(tagName: "map"): HTMLMapElement; + createElement(tagName: "marquee"): HTMLMarqueeElement; + createElement(tagName: "menu"): HTMLMenuElement; + createElement(tagName: "meta"): HTMLMetaElement; + createElement(tagName: "nextid"): HTMLNextIdElement; + createElement(tagName: "nobr"): HTMLPhraseElement; + createElement(tagName: "object"): HTMLObjectElement; + createElement(tagName: "ol"): HTMLOListElement; + createElement(tagName: "optgroup"): HTMLOptGroupElement; + createElement(tagName: "option"): HTMLOptionElement; + createElement(tagName: "p"): HTMLParagraphElement; + createElement(tagName: "param"): HTMLParamElement; + createElement(tagName: "plaintext"): HTMLBlockElement; + createElement(tagName: "pre"): HTMLPreElement; + createElement(tagName: "progress"): HTMLProgressElement; + createElement(tagName: "q"): HTMLQuoteElement; + createElement(tagName: "rt"): HTMLPhraseElement; + createElement(tagName: "ruby"): HTMLPhraseElement; + createElement(tagName: "s"): HTMLPhraseElement; + createElement(tagName: "samp"): HTMLPhraseElement; + createElement(tagName: "script"): HTMLScriptElement; + createElement(tagName: "select"): HTMLSelectElement; + createElement(tagName: "small"): HTMLPhraseElement; + createElement(tagName: "source"): HTMLSourceElement; + createElement(tagName: "span"): HTMLSpanElement; + createElement(tagName: "strike"): HTMLPhraseElement; + createElement(tagName: "strong"): HTMLPhraseElement; + createElement(tagName: "style"): HTMLStyleElement; + createElement(tagName: "sub"): HTMLPhraseElement; + createElement(tagName: "sup"): HTMLPhraseElement; + createElement(tagName: "table"): HTMLTableElement; + createElement(tagName: "tbody"): HTMLTableSectionElement; + createElement(tagName: "td"): HTMLTableDataCellElement; + createElement(tagName: "textarea"): HTMLTextAreaElement; + createElement(tagName: "tfoot"): HTMLTableSectionElement; + createElement(tagName: "th"): HTMLTableHeaderCellElement; + createElement(tagName: "thead"): HTMLTableSectionElement; + createElement(tagName: "title"): HTMLTitleElement; + createElement(tagName: "tr"): HTMLTableRowElement; + createElement(tagName: "track"): HTMLTrackElement; + createElement(tagName: "tt"): HTMLPhraseElement; + createElement(tagName: "u"): HTMLPhraseElement; + createElement(tagName: "ul"): HTMLUListElement; + createElement(tagName: "var"): HTMLPhraseElement; + createElement(tagName: "video"): HTMLVideoElement; + createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; + createElement(tagName: "xmp"): HTMLBlockElement; + createElement(tagName: string): HTMLElement; + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "clipPath"): SVGClipPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "componentTransferFunction"): SVGComponentTransferFunctionElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "defs"): SVGDefsElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "desc"): SVGDescElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "ellipse"): SVGEllipseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feBlend"): SVGFEBlendElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feColorMatrix"): SVGFEColorMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComponentTransfer"): SVGFEComponentTransferElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feComposite"): SVGFECompositeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feConvolveMatrix"): SVGFEConvolveMatrixElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDiffuseLighting"): SVGFEDiffuseLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDisplacementMap"): SVGFEDisplacementMapElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feDistantLight"): SVGFEDistantLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFlood"): SVGFEFloodElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncA"): SVGFEFuncAElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncB"): SVGFEFuncBElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncG"): SVGFEFuncGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feFuncR"): SVGFEFuncRElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feGaussianBlur"): SVGFEGaussianBlurElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feImage"): SVGFEImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMerge"): SVGFEMergeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMergeNode"): SVGFEMergeNodeElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feMorphology"): SVGFEMorphologyElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feOffset"): SVGFEOffsetElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "fePointLight"): SVGFEPointLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpecularLighting"): SVGFESpecularLightingElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feSpotLight"): SVGFESpotLightElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTile"): SVGFETileElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "feTurbulence"): SVGFETurbulenceElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "filter"): SVGFilterElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "foreignObject"): SVGForeignObjectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "g"): SVGGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "image"): SVGImageElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "gradient"): SVGGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "line"): SVGLineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "linearGradient"): SVGLinearGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "marker"): SVGMarkerElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "mask"): SVGMaskElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "path"): SVGPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "metadata"): SVGMetadataElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "pattern"): SVGPatternElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polygon"): SVGPolygonElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "polyline"): SVGPolylineElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "radialGradient"): SVGRadialGradientElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "rect"): SVGRectElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "svg"): SVGSVGElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "script"): SVGScriptElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "stop"): SVGStopElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "style"): SVGStyleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "switch"): SVGSwitchElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "symbol"): SVGSymbolElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "tspan"): SVGTSpanElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textContent"): SVGTextContentElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "text"): SVGTextElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPath"): SVGTextPathElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "textPositioning"): SVGTextPositioningElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "title"): SVGTitleElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "use"): SVGUseElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "view"): SVGViewElement + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement + createElementNS(namespaceURI: string, qualifiedName: string): Element; + createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; + createNSResolver(nodeResolver: Node): XPathNSResolver; + /** + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list + * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createNodeIterator(root: Node, whatToShow?: number, filter?: NodeFilter, entityReferenceExpansion?: boolean): NodeIterator; + createProcessingInstruction(target: string, data: string): ProcessingInstruction; + /** + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + */ + createRange(): Range; + /** + * Creates a text string from the specified value. + * @param data String that specifies the nodeValue property of the text node. + */ + createTextNode(data: string): Text; + createTouch(view: any, target: EventTarget, identifier: number, pageX: number, pageY: number, screenX: number, screenY: number): Touch; + createTouchList(...touches: Touch[]): TouchList; + /** + * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. + * @param filter A custom NodeFilter function to use. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter, entityReferenceExpansion?: boolean): TreeWalker; + /** + * Returns the element for the specified x coordinate and the specified y coordinate. + * @param x The x-offset + * @param y The y-offset + */ + elementFromPoint(x: number, y: number): Element; + evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver, type: number, result: XPathResult): XPathResult; + /** + * Executes a command on the current document, current selection, or the given range. + * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. + * @param showUI Display the user interface, defaults to false. + * @param value Value to assign. + */ + execCommand(commandId: string, showUI?: boolean, value?: any): boolean; + /** + * Displays help information for the given command identifier. + * @param commandId Displays help information for the given command identifier. + */ + execCommandShowHelp(commandId: string): boolean; + exitFullscreen(): void; + exitPointerLock(): void; + /** + * Causes the element to receive the focus and executes the code specified by the onfocus event. + */ + focus(): void; + /** + * Returns a reference to the first object with the specified value of the ID or NAME attribute. + * @param elementId String that specifies the ID value. Case-insensitive. + */ + getElementById(elementId: string): HTMLElement; + getElementsByClassName(classNames: string): NodeListOf; + /** + * Gets a collection of objects based on the value of the NAME or ID attribute. + * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. + */ + getElementsByName(elementName: string): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(tagname: "a"): NodeListOf; + getElementsByTagName(tagname: "abbr"): NodeListOf; + getElementsByTagName(tagname: "acronym"): NodeListOf; + getElementsByTagName(tagname: "address"): NodeListOf; + getElementsByTagName(tagname: "applet"): NodeListOf; + getElementsByTagName(tagname: "area"): NodeListOf; + getElementsByTagName(tagname: "article"): NodeListOf; + getElementsByTagName(tagname: "aside"): NodeListOf; + getElementsByTagName(tagname: "audio"): NodeListOf; + getElementsByTagName(tagname: "b"): NodeListOf; + getElementsByTagName(tagname: "base"): NodeListOf; + getElementsByTagName(tagname: "basefont"): NodeListOf; + getElementsByTagName(tagname: "bdo"): NodeListOf; + getElementsByTagName(tagname: "big"): NodeListOf; + getElementsByTagName(tagname: "blockquote"): NodeListOf; + getElementsByTagName(tagname: "body"): NodeListOf; + getElementsByTagName(tagname: "br"): NodeListOf; + getElementsByTagName(tagname: "button"): NodeListOf; + getElementsByTagName(tagname: "canvas"): NodeListOf; + getElementsByTagName(tagname: "caption"): NodeListOf; + getElementsByTagName(tagname: "center"): NodeListOf; + getElementsByTagName(tagname: "circle"): NodeListOf; + getElementsByTagName(tagname: "cite"): NodeListOf; + getElementsByTagName(tagname: "clippath"): NodeListOf; + getElementsByTagName(tagname: "code"): NodeListOf; + getElementsByTagName(tagname: "col"): NodeListOf; + getElementsByTagName(tagname: "colgroup"): NodeListOf; + getElementsByTagName(tagname: "datalist"): NodeListOf; + getElementsByTagName(tagname: "dd"): NodeListOf; + getElementsByTagName(tagname: "defs"): NodeListOf; + getElementsByTagName(tagname: "del"): NodeListOf; + getElementsByTagName(tagname: "desc"): NodeListOf; + getElementsByTagName(tagname: "dfn"): NodeListOf; + getElementsByTagName(tagname: "dir"): NodeListOf; + getElementsByTagName(tagname: "div"): NodeListOf; + getElementsByTagName(tagname: "dl"): NodeListOf; + getElementsByTagName(tagname: "dt"): NodeListOf; + getElementsByTagName(tagname: "ellipse"): NodeListOf; + getElementsByTagName(tagname: "em"): NodeListOf; + getElementsByTagName(tagname: "embed"): NodeListOf; + getElementsByTagName(tagname: "feblend"): NodeListOf; + getElementsByTagName(tagname: "fecolormatrix"): NodeListOf; + getElementsByTagName(tagname: "fecomponenttransfer"): NodeListOf; + getElementsByTagName(tagname: "fecomposite"): NodeListOf; + getElementsByTagName(tagname: "feconvolvematrix"): NodeListOf; + getElementsByTagName(tagname: "fediffuselighting"): NodeListOf; + getElementsByTagName(tagname: "fedisplacementmap"): NodeListOf; + getElementsByTagName(tagname: "fedistantlight"): NodeListOf; + getElementsByTagName(tagname: "feflood"): NodeListOf; + getElementsByTagName(tagname: "fefunca"): NodeListOf; + getElementsByTagName(tagname: "fefuncb"): NodeListOf; + getElementsByTagName(tagname: "fefuncg"): NodeListOf; + getElementsByTagName(tagname: "fefuncr"): NodeListOf; + getElementsByTagName(tagname: "fegaussianblur"): NodeListOf; + getElementsByTagName(tagname: "feimage"): NodeListOf; + getElementsByTagName(tagname: "femerge"): NodeListOf; + getElementsByTagName(tagname: "femergenode"): NodeListOf; + getElementsByTagName(tagname: "femorphology"): NodeListOf; + getElementsByTagName(tagname: "feoffset"): NodeListOf; + getElementsByTagName(tagname: "fepointlight"): NodeListOf; + getElementsByTagName(tagname: "fespecularlighting"): NodeListOf; + getElementsByTagName(tagname: "fespotlight"): NodeListOf; + getElementsByTagName(tagname: "fetile"): NodeListOf; + getElementsByTagName(tagname: "feturbulence"): NodeListOf; + getElementsByTagName(tagname: "fieldset"): NodeListOf; + getElementsByTagName(tagname: "figcaption"): NodeListOf; + getElementsByTagName(tagname: "figure"): NodeListOf; + getElementsByTagName(tagname: "filter"): NodeListOf; + getElementsByTagName(tagname: "font"): NodeListOf; + getElementsByTagName(tagname: "footer"): NodeListOf; + getElementsByTagName(tagname: "foreignobject"): NodeListOf; + getElementsByTagName(tagname: "form"): NodeListOf; + getElementsByTagName(tagname: "frame"): NodeListOf; + getElementsByTagName(tagname: "frameset"): NodeListOf; + getElementsByTagName(tagname: "g"): NodeListOf; + getElementsByTagName(tagname: "h1"): NodeListOf; + getElementsByTagName(tagname: "h2"): NodeListOf; + getElementsByTagName(tagname: "h3"): NodeListOf; + getElementsByTagName(tagname: "h4"): NodeListOf; + getElementsByTagName(tagname: "h5"): NodeListOf; + getElementsByTagName(tagname: "h6"): NodeListOf; + getElementsByTagName(tagname: "head"): NodeListOf; + getElementsByTagName(tagname: "header"): NodeListOf; + getElementsByTagName(tagname: "hgroup"): NodeListOf; + getElementsByTagName(tagname: "hr"): NodeListOf; + getElementsByTagName(tagname: "html"): NodeListOf; + getElementsByTagName(tagname: "i"): NodeListOf; + getElementsByTagName(tagname: "iframe"): NodeListOf; + getElementsByTagName(tagname: "image"): NodeListOf; + getElementsByTagName(tagname: "img"): NodeListOf; + getElementsByTagName(tagname: "input"): NodeListOf; + getElementsByTagName(tagname: "ins"): NodeListOf; + getElementsByTagName(tagname: "isindex"): NodeListOf; + getElementsByTagName(tagname: "kbd"): NodeListOf; + getElementsByTagName(tagname: "keygen"): NodeListOf; + getElementsByTagName(tagname: "label"): NodeListOf; + getElementsByTagName(tagname: "legend"): NodeListOf; + getElementsByTagName(tagname: "li"): NodeListOf; + getElementsByTagName(tagname: "line"): NodeListOf; + getElementsByTagName(tagname: "lineargradient"): NodeListOf; + getElementsByTagName(tagname: "link"): NodeListOf; + getElementsByTagName(tagname: "listing"): NodeListOf; + getElementsByTagName(tagname: "map"): NodeListOf; + getElementsByTagName(tagname: "mark"): NodeListOf; + getElementsByTagName(tagname: "marker"): NodeListOf; + getElementsByTagName(tagname: "marquee"): NodeListOf; + getElementsByTagName(tagname: "mask"): NodeListOf; + getElementsByTagName(tagname: "menu"): NodeListOf; + getElementsByTagName(tagname: "meta"): NodeListOf; + getElementsByTagName(tagname: "metadata"): NodeListOf; + getElementsByTagName(tagname: "nav"): NodeListOf; + getElementsByTagName(tagname: "nextid"): NodeListOf; + getElementsByTagName(tagname: "nobr"): NodeListOf; + getElementsByTagName(tagname: "noframes"): NodeListOf; + getElementsByTagName(tagname: "noscript"): NodeListOf; + getElementsByTagName(tagname: "object"): NodeListOf; + getElementsByTagName(tagname: "ol"): NodeListOf; + getElementsByTagName(tagname: "optgroup"): NodeListOf; + getElementsByTagName(tagname: "option"): NodeListOf; + getElementsByTagName(tagname: "p"): NodeListOf; + getElementsByTagName(tagname: "param"): NodeListOf; + getElementsByTagName(tagname: "path"): NodeListOf; + getElementsByTagName(tagname: "pattern"): NodeListOf; + getElementsByTagName(tagname: "plaintext"): NodeListOf; + getElementsByTagName(tagname: "polygon"): NodeListOf; + getElementsByTagName(tagname: "polyline"): NodeListOf; + getElementsByTagName(tagname: "pre"): NodeListOf; + getElementsByTagName(tagname: "progress"): NodeListOf; + getElementsByTagName(tagname: "q"): NodeListOf; + getElementsByTagName(tagname: "radialgradient"): NodeListOf; + getElementsByTagName(tagname: "rect"): NodeListOf; + getElementsByTagName(tagname: "rt"): NodeListOf; + getElementsByTagName(tagname: "ruby"): NodeListOf; + getElementsByTagName(tagname: "s"): NodeListOf; + getElementsByTagName(tagname: "samp"): NodeListOf; + getElementsByTagName(tagname: "script"): NodeListOf; + getElementsByTagName(tagname: "section"): NodeListOf; + getElementsByTagName(tagname: "select"): NodeListOf; + getElementsByTagName(tagname: "small"): NodeListOf; + getElementsByTagName(tagname: "source"): NodeListOf; + getElementsByTagName(tagname: "span"): NodeListOf; + getElementsByTagName(tagname: "stop"): NodeListOf; + getElementsByTagName(tagname: "strike"): NodeListOf; + getElementsByTagName(tagname: "strong"): NodeListOf; + getElementsByTagName(tagname: "style"): NodeListOf; + getElementsByTagName(tagname: "sub"): NodeListOf; + getElementsByTagName(tagname: "sup"): NodeListOf; + getElementsByTagName(tagname: "svg"): NodeListOf; + getElementsByTagName(tagname: "switch"): NodeListOf; + getElementsByTagName(tagname: "symbol"): NodeListOf; + getElementsByTagName(tagname: "table"): NodeListOf; + getElementsByTagName(tagname: "tbody"): NodeListOf; + getElementsByTagName(tagname: "td"): NodeListOf; + getElementsByTagName(tagname: "text"): NodeListOf; + getElementsByTagName(tagname: "textpath"): NodeListOf; + getElementsByTagName(tagname: "textarea"): NodeListOf; + getElementsByTagName(tagname: "tfoot"): NodeListOf; + getElementsByTagName(tagname: "th"): NodeListOf; + getElementsByTagName(tagname: "thead"): NodeListOf; + getElementsByTagName(tagname: "title"): NodeListOf; + getElementsByTagName(tagname: "tr"): NodeListOf; + getElementsByTagName(tagname: "track"): NodeListOf; + getElementsByTagName(tagname: "tspan"): NodeListOf; + getElementsByTagName(tagname: "tt"): NodeListOf; + getElementsByTagName(tagname: "u"): NodeListOf; + getElementsByTagName(tagname: "ul"): NodeListOf; + getElementsByTagName(tagname: "use"): NodeListOf; + getElementsByTagName(tagname: "var"): NodeListOf; + getElementsByTagName(tagname: "video"): NodeListOf; + getElementsByTagName(tagname: "view"): NodeListOf; + getElementsByTagName(tagname: "wbr"): NodeListOf; + getElementsByTagName(tagname: "x-ms-webview"): NodeListOf; + getElementsByTagName(tagname: "xmp"): NodeListOf; + getElementsByTagName(tagname: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; + /** + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + */ + getSelection(): Selection; + /** + * Gets a value indicating whether the object currently has focus. + */ + hasFocus(): boolean; + importNode(importedNode: Node, deep: boolean): Node; + msElementsFromPoint(x: number, y: number): NodeList; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; + /** + * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. + * @param url Specifies a MIME type for the document. + * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. + * @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; + /** + * 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. + */ + queryCommandEnabled(commandId: string): boolean; + /** + * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. + * @param commandId String that specifies a command identifier. + */ + queryCommandIndeterm(commandId: string): boolean; + /** + * Returns a Boolean value that indicates the current state of the command. + * @param commandId String that specifies a command identifier. + */ + queryCommandState(commandId: string): boolean; + /** + * Returns a Boolean value that indicates whether the current command is supported on the current range. + * @param commandId Specifies a command identifier. + */ + queryCommandSupported(commandId: string): boolean; + /** + * Retrieves the string associated with a command. + * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. + */ + queryCommandText(commandId: string): string; + /** + * Returns the current value of the document, range, or current selection for the given command. + * @param commandId String that specifies a command identifier. + */ + queryCommandValue(commandId: string): string; + releaseEvents(): void; + /** + * Allows updating the print settings for the page. + */ + updateSettings(): void; + webkitCancelFullScreen(): void; + webkitExitFullscreen(): void; + /** + * Writes one or more HTML expressions to a document in the specified window. + * @param content Specifies the text and HTML tags to write. + */ + write(...content: string[]): void; + /** + * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. + * @param content The text and HTML tags to write. + */ + writeln(...content: string[]): void; + createElement(tagName: "picture"): HTMLPictureElement; + getElementsByTagName(tagname: "picture"): NodeListOf; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "fullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "fullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerlockchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointerlockerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Document: { + prototype: Document; + new(): Document; +} + +interface DocumentFragment extends Node, NodeSelector { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DocumentFragment: { + prototype: DocumentFragment; + new(): DocumentFragment; +} + +interface DocumentType extends Node, ChildNode { + entities: NamedNodeMap; + internalSubset: string; + name: string; + notations: NamedNodeMap; + publicId: string; + systemId: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DocumentType: { + prototype: DocumentType; + new(): DocumentType; +} + +interface DragEvent extends MouseEvent { + dataTransfer: DataTransfer; + initDragEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, dataTransferArg: DataTransfer): void; + msConvertURL(file: File, targetType: string, targetURL?: string): void; +} + +declare var DragEvent: { + prototype: DragEvent; + new(): DragEvent; +} + +interface DynamicsCompressorNode extends AudioNode { + attack: AudioParam; + knee: AudioParam; + ratio: AudioParam; + reduction: AudioParam; + release: AudioParam; + threshold: AudioParam; +} + +declare var DynamicsCompressorNode: { + prototype: DynamicsCompressorNode; + new(): DynamicsCompressorNode; +} + +interface EXT_texture_filter_anisotropic { + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +declare var EXT_texture_filter_anisotropic: { + prototype: EXT_texture_filter_anisotropic; + new(): EXT_texture_filter_anisotropic; + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode { + classList: DOMTokenList; + clientHeight: number; + clientLeft: number; + clientTop: number; + clientWidth: number; + msContentZoomFactor: number; + msRegionOverflow: string; + onariarequest: (ev: AriaRequestEvent) => any; + oncommand: (ev: CommandEvent) => any; + ongotpointercapture: (ev: PointerEvent) => any; + onlostpointercapture: (ev: PointerEvent) => any; + onmsgesturechange: (ev: MSGestureEvent) => any; + onmsgesturedoubletap: (ev: MSGestureEvent) => any; + onmsgestureend: (ev: MSGestureEvent) => any; + onmsgesturehold: (ev: MSGestureEvent) => any; + onmsgesturestart: (ev: MSGestureEvent) => any; + onmsgesturetap: (ev: MSGestureEvent) => any; + onmsgotpointercapture: (ev: MSPointerEvent) => any; + onmsinertiastart: (ev: MSGestureEvent) => any; + onmslostpointercapture: (ev: MSPointerEvent) => any; + onmspointercancel: (ev: MSPointerEvent) => any; + onmspointerdown: (ev: MSPointerEvent) => any; + onmspointerenter: (ev: MSPointerEvent) => any; + onmspointerleave: (ev: MSPointerEvent) => any; + onmspointermove: (ev: MSPointerEvent) => any; + onmspointerout: (ev: MSPointerEvent) => any; + onmspointerover: (ev: MSPointerEvent) => any; + onmspointerup: (ev: MSPointerEvent) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + onwebkitfullscreenchange: (ev: Event) => any; + onwebkitfullscreenerror: (ev: Event) => any; + scrollHeight: number; + scrollLeft: number; + scrollTop: number; + scrollWidth: number; + tagName: string; + id: string; + className: string; + innerHTML: string; + getAttribute(name?: string): string; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNode(name: string): Attr; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + getBoundingClientRect(): ClientRect; + getClientRects(): ClientRectList; + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "acronym"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "applet"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "basefont"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "big"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "center"): NodeListOf; + getElementsByTagName(name: "circle"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "clippath"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "defs"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "desc"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "dir"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "ellipse"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "feblend"): NodeListOf; + getElementsByTagName(name: "fecolormatrix"): NodeListOf; + getElementsByTagName(name: "fecomponenttransfer"): NodeListOf; + getElementsByTagName(name: "fecomposite"): NodeListOf; + getElementsByTagName(name: "feconvolvematrix"): NodeListOf; + getElementsByTagName(name: "fediffuselighting"): NodeListOf; + getElementsByTagName(name: "fedisplacementmap"): NodeListOf; + getElementsByTagName(name: "fedistantlight"): NodeListOf; + getElementsByTagName(name: "feflood"): NodeListOf; + getElementsByTagName(name: "fefunca"): NodeListOf; + getElementsByTagName(name: "fefuncb"): NodeListOf; + getElementsByTagName(name: "fefuncg"): NodeListOf; + getElementsByTagName(name: "fefuncr"): NodeListOf; + getElementsByTagName(name: "fegaussianblur"): NodeListOf; + getElementsByTagName(name: "feimage"): NodeListOf; + getElementsByTagName(name: "femerge"): NodeListOf; + getElementsByTagName(name: "femergenode"): NodeListOf; + getElementsByTagName(name: "femorphology"): NodeListOf; + getElementsByTagName(name: "feoffset"): NodeListOf; + getElementsByTagName(name: "fepointlight"): NodeListOf; + getElementsByTagName(name: "fespecularlighting"): NodeListOf; + getElementsByTagName(name: "fespotlight"): NodeListOf; + getElementsByTagName(name: "fetile"): NodeListOf; + getElementsByTagName(name: "feturbulence"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "filter"): NodeListOf; + getElementsByTagName(name: "font"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "foreignobject"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "frame"): NodeListOf; + getElementsByTagName(name: "frameset"): NodeListOf; + getElementsByTagName(name: "g"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "image"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "isindex"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "keygen"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "line"): NodeListOf; + getElementsByTagName(name: "lineargradient"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "listing"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "marker"): NodeListOf; + getElementsByTagName(name: "marquee"): NodeListOf; + getElementsByTagName(name: "mask"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "metadata"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "nextid"): NodeListOf; + getElementsByTagName(name: "nobr"): NodeListOf; + getElementsByTagName(name: "noframes"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "path"): NodeListOf; + getElementsByTagName(name: "pattern"): NodeListOf; + getElementsByTagName(name: "plaintext"): NodeListOf; + getElementsByTagName(name: "polygon"): NodeListOf; + getElementsByTagName(name: "polyline"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "radialgradient"): NodeListOf; + getElementsByTagName(name: "rect"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "source"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "stop"): NodeListOf; + getElementsByTagName(name: "strike"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "svg"): NodeListOf; + getElementsByTagName(name: "switch"): NodeListOf; + getElementsByTagName(name: "symbol"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "text"): NodeListOf; + getElementsByTagName(name: "textpath"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "tspan"): NodeListOf; + getElementsByTagName(name: "tt"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "use"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "view"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getElementsByTagName(name: "x-ms-webview"): NodeListOf; + getElementsByTagName(name: "xmp"): NodeListOf; + getElementsByTagName(name: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; + hasAttribute(name: string): boolean; + hasAttributeNS(namespaceURI: string, localName: string): boolean; + msGetRegionContent(): MSRangeCollection; + msGetUntransformedBounds(): ClientRect; + msMatchesSelector(selectors: string): boolean; + msReleasePointerCapture(pointerId: number): void; + msSetPointerCapture(pointerId: number): void; + msZoomTo(args: MsZoomToOptions): void; + releasePointerCapture(pointerId: number): void; + removeAttribute(name?: string): void; + removeAttributeNS(namespaceURI: string, localName: string): void; + removeAttributeNode(oldAttr: Attr): Attr; + requestFullscreen(): void; + requestPointerLock(): void; + setAttribute(name: string, value: string): void; + setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; + setAttributeNode(newAttr: Attr): Attr; + setAttributeNodeNS(newAttr: Attr): Attr; + setPointerCapture(pointerId: number): void; + webkitMatchesSelector(selectors: string): boolean; + webkitRequestFullScreen(): void; + webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; + matches(selector: string): boolean; + getElementsByTagName(tagname: "picture"): NodeListOf; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Element: { + prototype: Element; + new(): Element; +} + +interface ErrorEvent extends Event { + colno: number; + error: any; + filename: string; + lineno: number; + message: string; + initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; +} + +declare var ErrorEvent: { + prototype: ErrorEvent; + new(): ErrorEvent; +} + +interface Event { + bubbles: boolean; + cancelBubble: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + returnValue: boolean; + srcElement: Element; + target: EventTarget; + timeStamp: number; + type: string; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + preventDefault(): void; + stopImmediatePropagation(): void; + stopPropagation(): void; + AT_TARGET: number; + BUBBLING_PHASE: number; + CAPTURING_PHASE: number; +} + +declare var Event: { + prototype: Event; + new(type: string, eventInitDict?: EventInit): Event; + AT_TARGET: number; + BUBBLING_PHASE: number; + CAPTURING_PHASE: number; +} + +interface EventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + dispatchEvent(evt: Event): boolean; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var EventTarget: { + prototype: EventTarget; + new(): EventTarget; +} + +interface External { +} + +declare var External: { + prototype: External; + new(): External; +} + +interface File extends Blob { + lastModifiedDate: any; + name: string; +} + +declare var File: { + prototype: File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; +} + +interface FileList { + length: number; + item(index: number): File; + [index: number]: File; +} + +declare var FileList: { + prototype: FileList; + new(): FileList; +} + +interface FileReader extends EventTarget, MSBaseReader { + error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsBinaryString(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var FileReader: { + prototype: FileReader; + new(): FileReader; +} + +interface FocusEvent extends UIEvent { + relatedTarget: EventTarget; + initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; +} + +declare var FocusEvent: { + prototype: FocusEvent; + new(typeArg: string, eventInitDict?: FocusEventInit): FocusEvent; +} + +interface FormData { + append(name: any, value: any, blobName?: string): void; +} + +declare var FormData: { + prototype: FormData; + new (form?: HTMLFormElement): FormData; +} + +interface GainNode extends AudioNode { + gain: AudioParam; +} + +declare var GainNode: { + prototype: GainNode; + new(): GainNode; +} + +interface Gamepad { + axes: number[]; + buttons: GamepadButton[]; + connected: boolean; + id: string; + index: number; + mapping: string; + timestamp: number; +} + +declare var Gamepad: { + prototype: Gamepad; + new(): Gamepad; +} + +interface GamepadButton { + pressed: boolean; + value: number; +} + +declare var GamepadButton: { + prototype: GamepadButton; + new(): GamepadButton; +} + +interface GamepadEvent extends Event { + gamepad: Gamepad; +} + +declare var GamepadEvent: { + prototype: GamepadEvent; + new(): GamepadEvent; +} + +interface Geolocation { + clearWatch(watchId: number): void; + getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; + watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; +} + +declare var Geolocation: { + prototype: Geolocation; + new(): Geolocation; +} + +interface HTMLAllCollection extends HTMLCollection { + namedItem(name: string): Element; +} + +declare var HTMLAllCollection: { + prototype: HTMLAllCollection; + new(): HTMLAllCollection; +} + +interface HTMLAnchorElement extends HTMLElement { + Methods: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Contains the anchor portion of the URL including the hash sign (#). + */ + hash: string; + /** + * Contains the hostname and port values of the URL. + */ + host: string; + /** + * Contains the hostname of a URL. + */ + hostname: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; + mimeType: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + nameProp: string; + /** + * Contains the pathname of the URL. + */ + pathname: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Contains the protocol of the URL. + */ + protocol: string; + protocolLong: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + type: string; + urn: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} + +declare var HTMLAnchorElement: { + prototype: HTMLAnchorElement; + new(): HTMLAnchorElement; +} + +interface HTMLAppletElement extends HTMLElement { + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; + align: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + border: string; + code: string; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + /** + * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. + */ + contentDocument: Document; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. + */ + declare: boolean; + form: HTMLFormElement; + /** + * Sets or retrieves the height of the object. + */ + height: string; + hspace: number; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + object: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + vspace: number; + width: number; +} + +declare var HTMLAppletElement: { + prototype: HTMLAppletElement; + new(): HTMLAppletElement; +} + +interface HTMLAreaElement extends HTMLElement { + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Sets or retrieves the subsection of the href property that follows the number sign (#). + */ + hash: string; + /** + * Sets or retrieves the hostname and port number of the location or URL. + */ + host: string; + /** + * Sets or retrieves the host name part of the location or URL. + */ + hostname: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or gets whether clicks in this region cause action. + */ + noHref: boolean; + /** + * Sets or retrieves the file name or path specified by the object. + */ + pathname: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Sets or retrieves the protocol portion of a URL. + */ + protocol: string; + rel: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} + +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new(): HTMLAreaElement; +} + +interface HTMLAreasCollection extends HTMLCollection { + /** + * Adds an element to the areas, controlRange, or options collection. + */ + add(element: HTMLElement, before?: HTMLElement | number): void; + /** + * Removes an element from the collection. + */ + remove(index?: number): void; +} + +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new(): HTMLAreasCollection; +} + +interface HTMLAudioElement extends HTMLMediaElement { +} + +declare var HTMLAudioElement: { + prototype: HTMLAudioElement; + new(): HTMLAudioElement; +} + +interface HTMLBRElement extends HTMLElement { + /** + * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. + */ + clear: string; +} + +declare var HTMLBRElement: { + prototype: HTMLBRElement; + new(): HTMLBRElement; +} + +interface HTMLBaseElement extends HTMLElement { + /** + * Gets or sets the baseline URL on which relative links are based. + */ + href: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; +} + +declare var HTMLBaseElement: { + prototype: HTMLBaseElement; + new(): HTMLBaseElement; +} + +interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; + /** + * Sets or retrieves the font size of the object. + */ + size: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new(): HTMLBaseFontElement; +} + +interface HTMLBlockElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + clear: string; + /** + * Sets or retrieves the width of the object. + */ + width: number; +} + +declare var HTMLBlockElement: { + prototype: HTMLBlockElement; + new(): HTMLBlockElement; +} + +interface HTMLBodyElement extends HTMLElement { + aLink: any; + background: string; + bgColor: any; + bgProperties: string; + link: any; + noWrap: boolean; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onblur: (ev: FocusEvent) => any; + onerror: (ev: Event) => any; + onfocus: (ev: FocusEvent) => any; + onhashchange: (ev: HashChangeEvent) => any; + onload: (ev: Event) => any; + onmessage: (ev: MessageEvent) => any; + onoffline: (ev: Event) => any; + ononline: (ev: Event) => any; + onorientationchange: (ev: Event) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onpopstate: (ev: PopStateEvent) => any; + onresize: (ev: UIEvent) => any; + onstorage: (ev: StorageEvent) => any; + onunload: (ev: Event) => any; + text: any; + vLink: any; + createTextRange(): TextRange; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLBodyElement: { + prototype: HTMLBodyElement; + new(): HTMLBodyElement; +} + +interface HTMLButtonElement extends HTMLElement { + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + status: any; + /** + * Gets the classification and default behavior of the button. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Sets or retrieves the default or selected value of the control. + */ + value: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +declare var HTMLButtonElement: { + prototype: HTMLButtonElement; + new(): HTMLButtonElement; +} + +interface HTMLCanvasElement extends HTMLElement { + /** + * Gets or sets the height of a canvas element on a document. + */ + height: number; + /** + * Gets or sets the width of a canvas element on a document. + */ + width: number; + /** + * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. + * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); + */ + getContext(contextId: "2d"): CanvasRenderingContext2D; + getContext(contextId: "experimental-webgl"): WebGLRenderingContext; + getContext(contextId: string, ...args: any[]): CanvasRenderingContext2D | WebGLRenderingContext; + /** + * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. + */ + msToBlob(): Blob; + /** + * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. + * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. + */ + toDataURL(type?: string, ...args: any[]): string; + toBlob(): Blob; +} + +declare var HTMLCanvasElement: { + prototype: HTMLCanvasElement; + new(): HTMLCanvasElement; +} + +interface HTMLCollection { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Retrieves an object from various collections. + */ + item(nameOrIndex?: any, optionalIndex?: any): Element; + /** + * Retrieves a select object or an object from an options collection. + */ + namedItem(name: string): Element; + [index: number]: Element; +} + +declare var HTMLCollection: { + prototype: HTMLCollection; + new(): HTMLCollection; +} + +interface HTMLDDElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} + +declare var HTMLDDElement: { + prototype: HTMLDDElement; + new(): HTMLDDElement; +} + +interface HTMLDListElement extends HTMLElement { + compact: boolean; +} + +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new(): HTMLDListElement; +} + +interface HTMLDTElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} + +declare var HTMLDTElement: { + prototype: HTMLDTElement; + new(): HTMLDTElement; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollection; +} + +declare var HTMLDataListElement: { + prototype: HTMLDataListElement; + new(): HTMLDataListElement; +} + +interface HTMLDirectoryElement extends HTMLElement { + compact: boolean; +} + +declare var HTMLDirectoryElement: { + prototype: HTMLDirectoryElement; + new(): HTMLDirectoryElement; +} + +interface HTMLDivElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} + +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new(): HTMLDivElement; +} + +interface HTMLDocument extends Document { +} + +declare var HTMLDocument: { + prototype: HTMLDocument; + new(): HTMLDocument; +} + +interface HTMLElement extends Element { + accessKey: string; + children: HTMLCollection; + contentEditable: string; + dataset: DOMStringMap; + dir: string; + draggable: boolean; + hidden: boolean; + hideFocus: boolean; + innerHTML: string; + innerText: string; + isContentEditable: boolean; + lang: string; + offsetHeight: number; + offsetLeft: number; + offsetParent: Element; + offsetTop: number; + offsetWidth: number; + onabort: (ev: Event) => any; + onactivate: (ev: UIEvent) => any; + onbeforeactivate: (ev: UIEvent) => any; + onbeforecopy: (ev: DragEvent) => any; + onbeforecut: (ev: DragEvent) => any; + onbeforedeactivate: (ev: UIEvent) => any; + onbeforepaste: (ev: DragEvent) => any; + onblur: (ev: FocusEvent) => any; + oncanplay: (ev: Event) => any; + oncanplaythrough: (ev: Event) => any; + onchange: (ev: Event) => any; + onclick: (ev: MouseEvent) => any; + oncontextmenu: (ev: PointerEvent) => any; + oncopy: (ev: DragEvent) => any; + oncuechange: (ev: Event) => any; + oncut: (ev: DragEvent) => any; + ondblclick: (ev: MouseEvent) => any; + ondeactivate: (ev: UIEvent) => any; + ondrag: (ev: DragEvent) => any; + ondragend: (ev: DragEvent) => any; + ondragenter: (ev: DragEvent) => any; + ondragleave: (ev: DragEvent) => any; + ondragover: (ev: DragEvent) => any; + ondragstart: (ev: DragEvent) => any; + ondrop: (ev: DragEvent) => any; + ondurationchange: (ev: Event) => any; + onemptied: (ev: Event) => any; + onended: (ev: Event) => any; + onerror: (ev: Event) => any; + onfocus: (ev: FocusEvent) => any; + oninput: (ev: Event) => any; + onkeydown: (ev: KeyboardEvent) => any; + onkeypress: (ev: KeyboardEvent) => any; + onkeyup: (ev: KeyboardEvent) => any; + onload: (ev: Event) => any; + onloadeddata: (ev: Event) => any; + onloadedmetadata: (ev: Event) => any; + onloadstart: (ev: Event) => any; + onmousedown: (ev: MouseEvent) => any; + onmouseenter: (ev: MouseEvent) => any; + onmouseleave: (ev: MouseEvent) => any; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onmouseover: (ev: MouseEvent) => any; + onmouseup: (ev: MouseEvent) => any; + onmousewheel: (ev: MouseWheelEvent) => any; + onmscontentzoom: (ev: UIEvent) => any; + onmsmanipulationstatechanged: (ev: MSManipulationEvent) => any; + onpaste: (ev: DragEvent) => any; + onpause: (ev: Event) => any; + onplay: (ev: Event) => any; + onplaying: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + onratechange: (ev: Event) => any; + onreset: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + onseeked: (ev: Event) => any; + onseeking: (ev: Event) => any; + onselect: (ev: UIEvent) => any; + onselectstart: (ev: Event) => any; + onstalled: (ev: Event) => any; + onsubmit: (ev: Event) => any; + onsuspend: (ev: Event) => any; + ontimeupdate: (ev: Event) => any; + onvolumechange: (ev: Event) => any; + onwaiting: (ev: Event) => any; + outerHTML: string; + outerText: string; + spellcheck: boolean; + style: CSSStyleDeclaration; + tabIndex: number; + title: string; + blur(): void; + click(): void; + dragDrop(): boolean; + focus(): void; + insertAdjacentElement(position: string, insertedElement: Element): Element; + insertAdjacentHTML(where: string, html: string): void; + insertAdjacentText(where: string, text: string): void; + msGetInputContext(): MSInputMethodContext; + scrollIntoView(top?: boolean): void; + setActive(): void; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLElement: { + prototype: HTMLElement; + new(): HTMLElement; +} + +interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves the height of the object. + */ + height: string; + hidden: any; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the palette used for the embedded document. + */ + palette: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + pluginspage: string; + readyState: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the height and width units of the embed object. + */ + units: string; + /** + * Sets or retrieves the width of the object. + */ + width: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLEmbedElement: { + prototype: HTMLEmbedElement; + new(): HTMLEmbedElement; +} + +interface HTMLFieldSetElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +declare var HTMLFieldSetElement: { + prototype: HTMLFieldSetElement; + new(): HTMLFieldSetElement; +} + +interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new(): HTMLFontElement; +} + +interface HTMLFormElement extends HTMLElement { + /** + * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. + */ + acceptCharset: string; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Retrieves a collection, in source order, of all controls in a given form. + */ + elements: HTMLCollection; + /** + * Sets or retrieves the MIME encoding for the form. + */ + encoding: string; + /** + * Sets or retrieves the encoding type for the form. + */ + enctype: string; + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves how to send the form data to the server. + */ + method: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Designates a form that is not validated when submitted. + */ + noValidate: boolean; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Retrieves a form object or an object from an elements collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Retrieves a form object or an object from an elements collection. + */ + namedItem(name: string): any; + /** + * Fires when the user resets a form. + */ + reset(): void; + /** + * Fires when a FORM is about to be submitted. + */ + submit(): void; + [name: string]: any; +} + +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new(): HTMLFormElement; +} + +interface HTMLFrameElement extends HTMLElement, GetSVGDocument { + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves the height of the object. + */ + height: string | number; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the width of the object. + */ + width: string | number; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new(): HTMLFrameElement; +} + +interface HTMLFrameSetElement extends HTMLElement { + border: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the frame widths of the object. + */ + cols: string; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + name: string; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + /** + * Fires when the object loses the input focus. + */ + onblur: (ev: FocusEvent) => any; + onerror: (ev: Event) => any; + /** + * Fires when the object receives focus. + */ + onfocus: (ev: FocusEvent) => any; + onhashchange: (ev: HashChangeEvent) => any; + onload: (ev: Event) => any; + onmessage: (ev: MessageEvent) => any; + onoffline: (ev: Event) => any; + ononline: (ev: Event) => any; + onorientationchange: (ev: Event) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onresize: (ev: UIEvent) => any; + onstorage: (ev: StorageEvent) => any; + onunload: (ev: Event) => any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFrameSetElement: { + prototype: HTMLFrameSetElement; + new(): HTMLFrameSetElement; +} + +interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. + */ + noShade: boolean; + /** + * Sets or retrieves the width of the object. + */ + width: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new(): HTMLHRElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; +} + +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new(): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + clear: string; +} + +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new(): HTMLHeadingElement; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; +} + +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new(): HTMLHtmlElement; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + allowFullscreen: boolean; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the horizontal margin for the object. + */ + hspace: number; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + sandbox: DOMSettableTokenList; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves the width of the object. + */ + width: string; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLIFrameElement: { + prototype: HTMLIFrameElement; + new(): HTMLIFrameElement; +} + +interface HTMLImageElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + crossOrigin: string; + currentSrc: string; + /** + * Sets or retrieves the height of the object. + */ + height: number; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves whether the image is a server-side image map. + */ + isMap: boolean; + /** + * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. + */ + longDesc: string; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * The original height of the image resource before sizing. + */ + naturalHeight: number; + /** + * The original width of the image resource before sizing. + */ + naturalWidth: number; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + srcset: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves the width of the object. + */ + width: number; + x: number; + y: number; + msGetAsCastingSource(): any; +} + +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new(): HTMLImageElement; + create(): HTMLImageElement; +} + +interface HTMLInputElement extends HTMLElement { + /** + * Sets or retrieves a comma-separated list of content types. + */ + accept: string; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + checked: boolean; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + /** + * Sets or retrieves the state of the check box or radio button. + */ + defaultChecked: boolean; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + disabled: boolean; + /** + * Returns a FileList object on a file type input object. + */ + files: FileList; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + indeterminate: boolean; + /** + * Specifies the ID of a pre-defined datalist of options for an input element. + */ + list: HTMLElement; + /** + * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. + */ + max: string; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. + */ + min: string; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets or sets a string containing a regular expression that the user's input must match. + */ + pattern: string; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + readOnly: boolean; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + size: number; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + status: boolean; + /** + * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. + */ + step: string; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns the value of the data at the cursor's current position. + */ + value: string; + valueAsDate: Date; + /** + * Returns the input field value as a number. + */ + valueAsNumber: number; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Makes the selection equal to the current object. + */ + select(): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. + * @param n Value to decrement the value by. + */ + stepDown(n?: number): void; + /** + * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. + * @param n Value to increment the value by. + */ + stepUp(n?: number): void; +} + +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new(): HTMLInputElement; +} + +interface HTMLIsIndexElement extends HTMLElement { + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + prompt: string; +} + +declare var HTMLIsIndexElement: { + prototype: HTMLIsIndexElement; + new(): HTMLIsIndexElement; +} + +interface HTMLLIElement extends HTMLElement { + type: string; + /** + * Sets or retrieves the value of a list item. + */ + value: number; +} + +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new(): HTMLLIElement; +} + +interface HTMLLabelElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; +} + +declare var HTMLLabelElement: { + prototype: HTMLLabelElement; + new(): HTMLLabelElement; +} + +interface HTMLLegendElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} + +declare var HTMLLegendElement: { + prototype: HTMLLegendElement; + new(): HTMLLegendElement; +} + +interface HTMLLinkElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + disabled: boolean; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLLinkElement: { + prototype: HTMLLinkElement; + new(): HTMLLinkElement; +} + +interface HTMLMapElement extends HTMLElement { + /** + * Retrieves a collection of the area objects defined for the given map object. + */ + areas: HTMLAreasCollection; + /** + * Sets or retrieves the name of the object. + */ + name: string; +} + +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new(): HTMLMapElement; +} + +interface HTMLMarqueeElement extends HTMLElement { + behavior: string; + bgColor: any; + direction: string; + height: string; + hspace: number; + loop: number; + onbounce: (ev: Event) => any; + onfinish: (ev: Event) => any; + onstart: (ev: Event) => any; + scrollAmount: number; + scrollDelay: number; + trueSpeed: boolean; + vspace: number; + width: string; + start(): void; + stop(): void; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new(): HTMLMarqueeElement; +} + +interface HTMLMediaElement extends HTMLElement { + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + audioTracks: AudioTrackList; + /** + * Gets or sets a value that indicates whether to start playing the media automatically. + */ + autoplay: boolean; + /** + * Gets a collection of buffered time ranges. + */ + buffered: TimeRanges; + /** + * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). + */ + controls: boolean; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + currentSrc: string; + /** + * Gets or sets the current playback position, in seconds. + */ + currentTime: number; + defaultMuted: boolean; + /** + * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. + */ + defaultPlaybackRate: number; + /** + * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. + */ + duration: number; + /** + * Gets information about whether the playback has ended or not. + */ + ended: boolean; + /** + * Returns an object representing the current error state of the audio or video element. + */ + error: MediaError; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + /** + * Specifies the purpose of the audio or video media, such as background audio or alerts. + */ + msAudioCategory: string; + /** + * Specifies the output device id that the audio will be sent to. + */ + msAudioDeviceType: string; + msGraphicsTrustStatus: MSGraphicsTrust; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + msKeys: MSMediaKeys; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Specifies whether or not to enable low-latency playback on the media element. + */ + msRealTime: boolean; + /** + * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. + */ + muted: boolean; + /** + * Gets the current network activity for the element. + */ + networkState: number; + onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; + /** + * Gets a flag that specifies whether playback is paused. + */ + paused: boolean; + /** + * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. + */ + playbackRate: number; + /** + * Gets TimeRanges for the current media resource that has been played. + */ + played: TimeRanges; + /** + * Gets or sets the current playback position, in seconds. + */ + preload: string; + readyState: number; + /** + * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. + */ + seekable: TimeRanges; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + seeking: boolean; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + textTracks: TextTrackList; + videoTracks: VideoTrackList; + /** + * Gets or sets the volume level for audio portions of the media element. + */ + volume: number; + addTextTrack(kind: string, label?: string, language?: string): TextTrack; + /** + * Returns a string that specifies whether the client can play a given media resource type. + */ + canPlayType(type: string): string; + /** + * Fires immediately after the client loads the object. + */ + load(): void; + /** + * Clears all effects from the media pipeline. + */ + msClearEffects(): void; + msGetAsCastingSource(): any; + /** + * Inserts the specified audio effect into media pipeline. + */ + msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetMediaKeys(mediaKeys: MSMediaKeys): void; + /** + * Specifies the media protection manager for a given media pipeline. + */ + msSetMediaProtectionManager(mediaProtectionManager?: any): void; + /** + * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. + */ + pause(): void; + /** + * Loads and starts playback of a media resource. + */ + play(): void; + HAVE_CURRENT_DATA: number; + HAVE_ENOUGH_DATA: number; + HAVE_FUTURE_DATA: number; + HAVE_METADATA: number; + HAVE_NOTHING: number; + NETWORK_EMPTY: number; + NETWORK_IDLE: number; + NETWORK_LOADING: number; + NETWORK_NO_SOURCE: number; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new(): HTMLMediaElement; + HAVE_CURRENT_DATA: number; + HAVE_ENOUGH_DATA: number; + HAVE_FUTURE_DATA: number; + HAVE_METADATA: number; + HAVE_NOTHING: number; + NETWORK_EMPTY: number; + NETWORK_IDLE: number; + NETWORK_LOADING: number; + NETWORK_NO_SOURCE: number; +} + +interface HTMLMenuElement extends HTMLElement { + compact: boolean; + type: string; +} + +declare var HTMLMenuElement: { + prototype: HTMLMenuElement; + new(): HTMLMenuElement; +} + +interface HTMLMetaElement extends HTMLElement { + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Gets or sets meta-information to associate with httpEquiv or name. + */ + content: string; + /** + * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. + */ + httpEquiv: string; + /** + * Sets or retrieves the value specified in the content attribute of the meta object. + */ + name: string; + /** + * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. + */ + scheme: string; + /** + * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. + */ + url: string; +} + +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new(): HTMLMetaElement; +} + +interface HTMLModElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; +} + +declare var HTMLModElement: { + prototype: HTMLModElement; + new(): HTMLModElement; +} + +interface HTMLNextIdElement extends HTMLElement { + n: string; +} + +declare var HTMLNextIdElement: { + prototype: HTMLNextIdElement; + new(): HTMLNextIdElement; +} + +interface HTMLOListElement extends HTMLElement { + compact: boolean; + /** + * The starting number. + */ + start: number; + type: string; +} + +declare var HTMLOListElement: { + prototype: HTMLOListElement; + new(): HTMLOListElement; +} + +interface HTMLObjectElement extends HTMLElement, GetSVGDocument { + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; + align: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + border: string; + /** + * Sets or retrieves the URL of the file containing the compiled Java class. + */ + code: string; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + declare: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the height of the object. + */ + height: string; + hspace: number; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the contained object. + */ + object: any; + readyState: number; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + vspace: number; + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLObjectElement: { + prototype: HTMLObjectElement; + new(): HTMLObjectElement; +} + +interface HTMLOptGroupElement extends HTMLElement { + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; +} + +declare var HTMLOptGroupElement: { + prototype: HTMLOptGroupElement; + new(): HTMLOptGroupElement; +} + +interface HTMLOptionElement extends HTMLElement { + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; +} + +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new(): HTMLOptionElement; + create(): HTMLOptionElement; +} + +interface HTMLParagraphElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + clear: string; +} + +declare var HTMLParagraphElement: { + prototype: HTMLParagraphElement; + new(): HTMLParagraphElement; +} + +interface HTMLParamElement extends HTMLElement { + /** + * Sets or retrieves the name of an input parameter for an element. + */ + name: string; + /** + * Sets or retrieves the content type of the resource designated by the value attribute. + */ + type: string; + /** + * Sets or retrieves the value of an input parameter for an element. + */ + value: string; + /** + * Sets or retrieves the data type of the value attribute. + */ + valueType: string; +} + +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new(): HTMLParamElement; +} + +interface HTMLPhraseElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; +} + +declare var HTMLPhraseElement: { + prototype: HTMLPhraseElement; + new(): HTMLPhraseElement; +} + +interface HTMLPreElement extends HTMLElement { + /** + * Indicates a citation by rendering text in italic type. + */ + cite: string; + clear: string; + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; +} + +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new(): HTMLPreElement; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Defines the maximum, or "done" value for a progress element. + */ + max: number; + /** + * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). + */ + position: number; + /** + * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. + */ + value: number; +} + +declare var HTMLProgressElement: { + prototype: HTMLProgressElement; + new(): HTMLProgressElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; +} + +declare var HTMLQuoteElement: { + prototype: HTMLQuoteElement; + new(): HTMLQuoteElement; +} + +interface HTMLScriptElement extends HTMLElement { + async: boolean; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the status of the script. + */ + defer: boolean; + /** + * Sets or retrieves the event for which the script is written. + */ + event: string; + /** + * Sets or retrieves the object that is bound to the event script. + */ + htmlFor: string; + /** + * Retrieves the URL to an external file that contains the source code or data. + */ + src: string; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + /** + * Sets or retrieves the MIME type for the associated scripting engine. + */ + type: string; +} + +declare var HTMLScriptElement: { + prototype: HTMLScriptElement; + new(): HTMLScriptElement; +} + +interface HTMLSelectElement extends HTMLElement { + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Sets or retrieves the name of the object. + */ + name: string; + options: HTMLCollection; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Sets or retrieves the index of the selected option in a select object. + */ + selectedIndex: number; + /** + * Sets or retrieves the number of rows in the list box. + */ + size: number; + /** + * Retrieves the type of select control based on the value of the MULTIPLE attribute. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + selectedOptions: HTMLCollection; + /** + * Adds an element to the areas, controlRange, or options collection. + * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. + * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. + */ + add(element: HTMLElement, before?: HTMLElement | number): void; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Retrieves a select object or an object from an options collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Retrieves a select object or an object from an options collection. + * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. + */ + namedItem(name: string): any; + /** + * Removes an element from the collection. + * @param index Number that specifies the zero-based index of the element to remove from the collection. + */ + remove(index?: number): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; + [name: string]: any; +} + +declare var HTMLSelectElement: { + prototype: HTMLSelectElement; + new(): HTMLSelectElement; +} + +interface HTMLSourceElement extends HTMLElement { + /** + * Gets or sets the intended media type of the media source. + */ + media: string; + msKeySystem: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; +} + +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new(): HTMLSourceElement; +} + +interface HTMLSpanElement extends HTMLElement { +} + +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new(): HTMLSpanElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLStyleElement: { + prototype: HTMLStyleElement; + new(): HTMLStyleElement; +} + +interface HTMLTableCaptionElement extends HTMLElement { + /** + * Sets or retrieves the alignment of the caption or legend. + */ + align: string; + /** + * Sets or retrieves whether the caption appears at the top or bottom of the table. + */ + vAlign: string; +} + +declare var HTMLTableCaptionElement: { + prototype: HTMLTableCaptionElement; + new(): HTMLTableCaptionElement; +} + +interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves abbreviated text for the object. + */ + abbr: string; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. + */ + axis: string; + bgColor: any; + /** + * Retrieves the position of the object in the cells collection of a row. + */ + cellIndex: number; + /** + * Sets or retrieves the number columns in the table that the object should span. + */ + colSpan: number; + /** + * Sets or retrieves a list of header cells that provide information for the object. + */ + headers: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; + /** + * Sets or retrieves how many rows in a table the cell should span. + */ + rowSpan: number; + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; + /** + * Sets or retrieves the width of the object. + */ + width: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableCellElement: { + prototype: HTMLTableCellElement; + new(): HTMLTableCellElement; +} + +interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves the alignment of the object relative to the display or table. + */ + align: string; + /** + * Sets or retrieves the number of columns in the group. + */ + span: number; + /** + * Sets or retrieves the width of the object. + */ + width: any; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new(): HTMLTableColElement; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { +} + +declare var HTMLTableDataCellElement: { + prototype: HTMLTableDataCellElement; + new(): HTMLTableDataCellElement; +} + +interface HTMLTableElement extends HTMLElement { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + bgColor: any; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Retrieves the caption object of a table. + */ + caption: HTMLTableCaptionElement; + /** + * Sets or retrieves the amount of space between the border of the cell and the content of the cell. + */ + cellPadding: string; + /** + * Sets or retrieves the amount of space between cells in a table. + */ + cellSpacing: string; + /** + * Sets or retrieves the number of columns in the table. + */ + cols: number; + /** + * Sets or retrieves the way the border frame around the table is displayed. + */ + frame: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Sets or retrieves which dividing lines (inner borders) are displayed. + */ + rules: string; + /** + * Sets or retrieves a description and/or structure of the object. + */ + summary: string; + /** + * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. + */ + tBodies: HTMLCollection; + /** + * Retrieves the tFoot object of the table. + */ + tFoot: HTMLTableSectionElement; + /** + * Retrieves the tHead object of the table. + */ + tHead: HTMLTableSectionElement; + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Creates an empty caption element in the table. + */ + createCaption(): HTMLTableCaptionElement; + /** + * Creates an empty tBody element in the table. + */ + createTBody(): HTMLTableSectionElement; + /** + * Creates an empty tFoot element in the table. + */ + createTFoot(): HTMLTableSectionElement; + /** + * Returns the tHead element object if successful, or null otherwise. + */ + createTHead(): HTMLTableSectionElement; + /** + * Deletes the caption element and its contents from the table. + */ + deleteCaption(): void; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Deletes the tFoot element and its contents from the table. + */ + deleteTFoot(): void; + /** + * Deletes the tHead element and its contents from the table. + */ + deleteTHead(): void; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLTableRowElement; +} + +declare var HTMLTableElement: { + prototype: HTMLTableElement; + new(): HTMLTableElement; +} + +interface HTMLTableHeaderCellElement extends HTMLTableCellElement { + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; +} + +declare var HTMLTableHeaderCellElement: { + prototype: HTMLTableHeaderCellElement; + new(): HTMLTableHeaderCellElement; +} + +interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + bgColor: any; + /** + * Retrieves a collection of all cells in the table row. + */ + cells: HTMLCollection; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the position of the object in the rows collection for the table. + */ + rowIndex: number; + /** + * Retrieves the position of the object in the collection. + */ + sectionRowIndex: number; + /** + * Removes the specified cell from the table row, as well as from the cells collection. + * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. + */ + deleteCell(index?: number): void; + /** + * Creates a new cell in the table row, and adds the cell to the cells collection. + * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. + */ + insertCell(index?: number): HTMLTableCellElement; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableRowElement: { + prototype: HTMLTableRowElement; + new(): HTMLTableRowElement; +} + +interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLTableRowElement; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new(): HTMLTableSectionElement; +} + +interface HTMLTextAreaElement extends HTMLElement { + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Sets or retrieves the width of the object. + */ + cols: number; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + disabled: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Sets or retrieves the value indicated whether the content of the object is read-only. + */ + readOnly: boolean; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: number; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + /** + * Sets or retrieves the value indicating whether the control is selected. + */ + status: any; + /** + * Retrieves the type of control. + */ + type: string; + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Retrieves or sets the text in the entry field of the textArea element. + */ + value: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Highlights the input area of a form element. + */ + select(): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; +} + +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new(): HTMLTextAreaElement; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} + +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new(): HTMLTitleElement; +} + +interface HTMLTrackElement extends HTMLElement { + default: boolean; + kind: string; + label: string; + readyState: number; + src: string; + srclang: string; + track: TextTrack; + ERROR: number; + LOADED: number; + LOADING: number; + NONE: number; +} + +declare var HTMLTrackElement: { + prototype: HTMLTrackElement; + new(): HTMLTrackElement; + ERROR: number; + LOADED: number; + LOADING: number; + NONE: number; +} + +interface HTMLUListElement extends HTMLElement { + compact: boolean; + type: string; +} + +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new(): HTMLUListElement; +} + +interface HTMLUnknownElement extends HTMLElement { +} + +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new(): HTMLUnknownElement; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the height of the video element. + */ + height: number; + msHorizontalMirror: boolean; + msIsLayoutOptimalForPlayback: boolean; + msIsStereo3D: boolean; + msStereo3DPackingMode: string; + msStereo3DRenderMode: string; + msZoom: boolean; + onMSVideoFormatChanged: (ev: Event) => any; + onMSVideoFrameStepCompleted: (ev: Event) => any; + onMSVideoOptimalLayoutChanged: (ev: Event) => any; + /** + * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. + */ + poster: string; + /** + * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoHeight: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoWidth: number; + webkitDisplayingFullscreen: boolean; + webkitSupportsFullscreen: boolean; + /** + * Gets or sets the width of the video element. + */ + width: number; + getVideoPlaybackQuality(): VideoPlaybackQuality; + msFrameStep(forward: boolean): void; + msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; + webkitEnterFullScreen(): void; + webkitEnterFullscreen(): void; + webkitExitFullScreen(): void; + webkitExitFullscreen(): void; + addEventListener(type: "MSContentZoom", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSManipulationStateChanged", listener: (ev: MSManipulationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFormatChanged", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; + addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new(): HTMLVideoElement; +} + +interface HashChangeEvent extends Event { + newURL: string; + oldURL: string; +} + +declare var HashChangeEvent: { + prototype: HashChangeEvent; + new(type: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface History { + length: number; + state: any; + back(distance?: any): void; + forward(distance?: any): void; + go(delta?: any): void; + pushState(statedata: any, title?: string, url?: string): void; + replaceState(statedata: any, title?: string, url?: string): void; +} + +declare var History: { + prototype: History; + new(): History; +} + +interface IDBCursor { + direction: string; + key: any; + primaryKey: any; + source: IDBObjectStore | IDBIndex; + advance(count: number): void; + continue(key?: any): void; + delete(): IDBRequest; + update(value: any): IDBRequest; + NEXT: string; + NEXT_NO_DUPLICATE: string; + PREV: string; + PREV_NO_DUPLICATE: string; +} + +declare var IDBCursor: { + prototype: IDBCursor; + new(): IDBCursor; + NEXT: string; + NEXT_NO_DUPLICATE: string; + PREV: string; + PREV_NO_DUPLICATE: string; +} + +interface IDBCursorWithValue extends IDBCursor { + value: any; +} + +declare var IDBCursorWithValue: { + prototype: IDBCursorWithValue; + new(): IDBCursorWithValue; +} + +interface IDBDatabase extends EventTarget { + name: string; + objectStoreNames: DOMStringList; + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + version: number; + close(): void; + createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; + deleteObjectStore(name: string): void; + transaction(storeNames: string | string[], mode?: string): IDBTransaction; + 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; +} + +declare var IDBDatabase: { + prototype: IDBDatabase; + new(): IDBDatabase; +} + +interface IDBFactory { + cmp(first: any, second: any): number; + deleteDatabase(name: string): IDBOpenDBRequest; + open(name: string, version?: number): IDBOpenDBRequest; +} + +declare var IDBFactory: { + prototype: IDBFactory; + new(): IDBFactory; +} + +interface IDBIndex { + keyPath: string | string[]; + name: string; + objectStore: IDBObjectStore; + unique: boolean; + multiEntry: boolean; + count(key?: any): IDBRequest; + get(key: any): IDBRequest; + getKey(key: any): IDBRequest; + openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; +} + +declare var IDBIndex: { + prototype: IDBIndex; + new(): IDBIndex; +} + +interface IDBKeyRange { + lower: any; + lowerOpen: boolean; + upper: any; + upperOpen: boolean; +} + +declare var IDBKeyRange: { + prototype: IDBKeyRange; + new(): IDBKeyRange; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + lowerBound(bound: any, open?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + upperBound(bound: any, open?: boolean): IDBKeyRange; +} + +interface IDBObjectStore { + indexNames: DOMStringList; + keyPath: string | string[]; + name: string; + transaction: IDBTransaction; + autoIncrement: boolean; + add(value: any, key?: any): IDBRequest; + clear(): IDBRequest; + count(key?: any): IDBRequest; + createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex; + delete(key: any): IDBRequest; + deleteIndex(indexName: string): void; + get(key: any): IDBRequest; + index(name: string): IDBIndex; + openCursor(range?: any, direction?: string): IDBRequest; + put(value: any, key?: any): IDBRequest; +} + +declare var IDBObjectStore: { + prototype: IDBObjectStore; + new(): IDBObjectStore; +} + +interface IDBOpenDBRequest extends IDBRequest { + onblocked: (ev: Event) => any; + onupgradeneeded: (ev: IDBVersionChangeEvent) => any; + addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBOpenDBRequest: { + prototype: IDBOpenDBRequest; + new(): IDBOpenDBRequest; +} + +interface IDBRequest extends EventTarget { + error: DOMError; + onerror: (ev: Event) => any; + onsuccess: (ev: Event) => any; + readyState: string; + result: any; + source: IDBObjectStore | IDBIndex | IDBCursor; + transaction: IDBTransaction; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBRequest: { + prototype: IDBRequest; + new(): IDBRequest; +} + +interface IDBTransaction extends EventTarget { + db: IDBDatabase; + error: DOMError; + mode: string; + onabort: (ev: Event) => any; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; + READ_ONLY: string; + READ_WRITE: string; + VERSION_CHANGE: string; + 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; +} + +declare var IDBTransaction: { + prototype: IDBTransaction; + new(): IDBTransaction; + READ_ONLY: string; + READ_WRITE: string; + VERSION_CHANGE: string; +} + +interface IDBVersionChangeEvent extends Event { + newVersion: number; + oldVersion: number; +} + +declare var IDBVersionChangeEvent: { + prototype: IDBVersionChangeEvent; + new(): IDBVersionChangeEvent; +} + +interface ImageData { + data: Uint8ClampedArray; + height: number; + width: number; +} + +declare var ImageData: { + prototype: ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; +} + +interface KeyboardEvent extends UIEvent { + altKey: boolean; + char: string; + charCode: number; + ctrlKey: boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_MOBILE: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; +} + +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new(typeArg: string, eventInitDict?: KeyboardEventInit): KeyboardEvent; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_MOBILE: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; +} + +interface Location { + hash: string; + host: string; + hostname: string; + href: string; + origin: string; + pathname: string; + port: string; + protocol: string; + search: string; + assign(url: string): void; + reload(forcedReload?: boolean): void; + replace(url: string): void; + toString(): string; +} + +declare var Location: { + prototype: Location; + new(): Location; +} + +interface LongRunningScriptDetectedEvent extends Event { + executionTime: number; + stopPageScriptExecution: boolean; +} + +declare var LongRunningScriptDetectedEvent: { + prototype: LongRunningScriptDetectedEvent; + new(): LongRunningScriptDetectedEvent; +} + +interface MSApp { + clearTemporaryWebDataAsync(): MSAppAsyncOperation; + createBlobFromRandomAccessStream(type: string, seeker: any): Blob; + createDataPackage(object: any): any; + createDataPackageFromSelection(): any; + createFileFromStorageFile(storageFile: any): File; + createStreamFromInputStream(type: string, inputStream: any): MSStream; + execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; + execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; + getCurrentPriority(): string; + getHtmlPrintDocumentSourceAsync(htmlDoc: any): any; + getViewId(view: any): any; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + pageHandlesAllApplicationActivations(enabled: boolean): void; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + terminateApp(exceptionObject: any): void; + CURRENT: string; + HIGH: string; + IDLE: string; + NORMAL: string; +} +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; +} + +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new(): MSBlobBuilder; +} + +interface MSCSSMatrix { + a: number; + b: number; + c: number; + d: number; + e: number; + f: number; + m11: number; + m12: number; + m13: number; + m14: number; + m21: number; + m22: number; + m23: number; + m24: number; + m31: number; + m32: number; + m33: number; + m34: number; + m41: number; + m42: number; + m43: number; + m44: number; + inverse(): MSCSSMatrix; + multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; + rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; + setMatrixValue(value: string): void; + skewX(angle: number): MSCSSMatrix; + skewY(angle: number): MSCSSMatrix; + toString(): string; + translate(x: number, y: number, z?: number): MSCSSMatrix; +} + +declare var MSCSSMatrix: { + prototype: MSCSSMatrix; + new(text?: string): MSCSSMatrix; +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} + +declare var MSGesture: { + prototype: MSGesture; + new(): MSGesture; +} + +interface MSGestureEvent extends UIEvent { + clientX: number; + clientY: number; + expansion: number; + gestureObject: any; + hwTimestamp: number; + offsetX: number; + offsetY: number; + rotation: number; + scale: number; + screenX: number; + screenY: number; + translationX: number; + translationY: number; + velocityAngular: number; + velocityExpansion: number; + velocityX: number; + velocityY: number; + initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +declare var MSGestureEvent: { + prototype: MSGestureEvent; + new(): MSGestureEvent; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +interface MSGraphicsTrust { + constrictionActive: boolean; + status: string; +} + +declare var MSGraphicsTrust: { + prototype: MSGraphicsTrust; + new(): MSGraphicsTrust; +} + +interface MSHTMLWebViewElement extends HTMLElement { + canGoBack: boolean; + canGoForward: boolean; + containsFullScreenElement: boolean; + documentTitle: string; + height: number; + settings: MSWebViewSettings; + src: string; + width: number; + addWebAllowedObject(name: string, applicationObject: any): void; + buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; + capturePreviewToBlobAsync(): MSWebViewAsyncOperation; + captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; + getDeferredPermissionRequestById(id: number): DeferredPermissionRequest; + getDeferredPermissionRequests(): DeferredPermissionRequest[]; + goBack(): void; + goForward(): void; + invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; + navigate(uri: string): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + navigateToString(contents: string): void; + navigateWithHttpRequestMessage(requestMessage: any): void; + refresh(): void; + stop(): void; +} + +declare var MSHTMLWebViewElement: { + prototype: MSHTMLWebViewElement; + new(): MSHTMLWebViewElement; +} + +interface MSInputMethodContext extends EventTarget { + compositionEndOffset: number; + compositionStartOffset: number; + oncandidatewindowhide: (ev: Event) => any; + oncandidatewindowshow: (ev: Event) => any; + oncandidatewindowupdate: (ev: Event) => any; + target: HTMLElement; + getCandidateWindowClientRect(): ClientRect; + getCompositionAlternatives(): string[]; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; + addEventListener(type: "MSCandidateWindowHide", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSCandidateWindowShow", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "MSCandidateWindowUpdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSInputMethodContext: { + prototype: MSInputMethodContext; + new(): MSInputMethodContext; +} + +interface MSManipulationEvent extends UIEvent { + currentState: number; + inertiaDestinationX: number; + inertiaDestinationY: number; + lastState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_CANCELLED: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_INERTIA: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_STOPPED: number; +} + +declare var MSManipulationEvent: { + prototype: MSManipulationEvent; + new(): MSManipulationEvent; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_CANCELLED: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_INERTIA: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_STOPPED: number; +} + +interface MSMediaKeyError { + code: number; + systemCode: number; + MS_MEDIA_KEYERR_CLIENT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_UNKNOWN: number; +} + +declare var MSMediaKeyError: { + prototype: MSMediaKeyError; + new(): MSMediaKeyError; + MS_MEDIA_KEYERR_CLIENT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_UNKNOWN: number; +} + +interface MSMediaKeyMessageEvent extends Event { + destinationURL: string; + message: Uint8Array; +} + +declare var MSMediaKeyMessageEvent: { + prototype: MSMediaKeyMessageEvent; + new(): MSMediaKeyMessageEvent; +} + +interface MSMediaKeyNeededEvent extends Event { + initData: Uint8Array; +} + +declare var MSMediaKeyNeededEvent: { + prototype: MSMediaKeyNeededEvent; + new(): MSMediaKeyNeededEvent; +} + +interface MSMediaKeySession extends EventTarget { + error: MSMediaKeyError; + keySystem: string; + sessionId: string; + close(): void; + update(key: Uint8Array): void; +} + +declare var MSMediaKeySession: { + prototype: MSMediaKeySession; + new(): MSMediaKeySession; +} + +interface MSMediaKeys { + keySystem: string; + createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; +} + +declare var MSMediaKeys: { + prototype: MSMediaKeys; + new(keySystem: string): MSMediaKeys; + isTypeSupported(keySystem: string, type?: string): boolean; +} + +interface MSMimeTypesCollection { + length: number; +} + +declare var MSMimeTypesCollection: { + prototype: MSMimeTypesCollection; + new(): MSMimeTypesCollection; +} + +interface MSPluginsCollection { + length: number; + refresh(reload?: boolean): void; +} + +declare var MSPluginsCollection: { + prototype: MSPluginsCollection; + new(): MSPluginsCollection; +} + +interface MSPointerEvent extends MouseEvent { + currentPoint: any; + height: number; + hwTimestamp: number; + intermediatePoints: any; + isPrimary: boolean; + pointerId: number; + pointerType: any; + pressure: number; + rotation: number; + tiltX: number; + tiltY: number; + width: number; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; + initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; +} + +declare var MSPointerEvent: { + prototype: MSPointerEvent; + new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; +} + +interface MSRangeCollection { + length: number; + item(index: number): Range; + [index: number]: Range; +} + +declare var MSRangeCollection: { + prototype: MSRangeCollection; + new(): MSRangeCollection; +} + +interface MSSiteModeEvent extends Event { + actionURL: string; + buttonID: number; +} + +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new(): MSSiteModeEvent; +} + +interface MSStream { + type: string; + msClose(): void; + msDetachStream(): any; +} + +declare var MSStream: { + prototype: MSStream; + new(): MSStream; +} + +interface MSStreamReader extends EventTarget, MSBaseReader { + error: DOMError; + readAsArrayBuffer(stream: MSStream, size?: number): void; + readAsBinaryString(stream: MSStream, size?: number): void; + readAsBlob(stream: MSStream, size?: number): void; + readAsDataURL(stream: MSStream, size?: number): void; + readAsText(stream: MSStream, encoding?: string, size?: number): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSStreamReader: { + prototype: MSStreamReader; + new(): MSStreamReader; +} + +interface MSWebViewAsyncOperation extends EventTarget { + error: DOMError; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + readyState: number; + result: any; + target: MSHTMLWebViewElement; + type: number; + start(): void; + COMPLETED: number; + ERROR: number; + STARTED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: 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 MSWebViewAsyncOperation: { + prototype: MSWebViewAsyncOperation; + new(): MSWebViewAsyncOperation; + COMPLETED: number; + ERROR: number; + STARTED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; +} + +interface MSWebViewSettings { + isIndexedDBEnabled: boolean; + isJavaScriptEnabled: boolean; +} + +declare var MSWebViewSettings: { + prototype: MSWebViewSettings; + new(): MSWebViewSettings; +} + +interface MediaElementAudioSourceNode extends AudioNode { +} + +declare var MediaElementAudioSourceNode: { + prototype: MediaElementAudioSourceNode; + new(): MediaElementAudioSourceNode; +} + +interface MediaError { + code: number; + msExtendedCode: number; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_DECODE: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MS_MEDIA_ERR_ENCRYPTED: number; +} + +declare var MediaError: { + prototype: MediaError; + new(): MediaError; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_DECODE: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MS_MEDIA_ERR_ENCRYPTED: number; +} + +interface MediaList { + length: number; + mediaText: string; + appendMedium(newMedium: string): void; + deleteMedium(oldMedium: string): void; + item(index: number): string; + toString(): string; + [index: number]: string; +} + +declare var MediaList: { + prototype: MediaList; + new(): MediaList; +} + +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + +interface MediaSource extends EventTarget { + activeSourceBuffers: SourceBufferList; + duration: number; + readyState: string; + sourceBuffers: SourceBufferList; + addSourceBuffer(type: string): SourceBuffer; + endOfStream(error?: number): void; + removeSourceBuffer(sourceBuffer: SourceBuffer): void; +} + +declare var MediaSource: { + prototype: MediaSource; + new(): MediaSource; + isTypeSupported(type: string): boolean; +} + +interface MessageChannel { + port1: MessagePort; + port2: MessagePort; +} + +declare var MessageChannel: { + prototype: MessageChannel; + new(): MessageChannel; +} + +interface MessageEvent extends Event { + data: any; + origin: string; + ports: any; + source: Window; + initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; +} + +declare var MessageEvent: { + prototype: MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; +} + +interface MessagePort extends EventTarget { + onmessage: (ev: MessageEvent) => any; + close(): void; + postMessage(message?: any, ports?: any): void; + start(): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MessagePort: { + prototype: MessagePort; + new(): MessagePort; +} + +interface MimeType { + description: string; + enabledPlugin: Plugin; + suffixes: string; + type: string; +} + +declare var MimeType: { + prototype: MimeType; + new(): MimeType; +} + +interface MimeTypeArray { + length: number; + item(index: number): Plugin; + namedItem(type: string): Plugin; + [index: number]: Plugin; +} + +declare var MimeTypeArray: { + prototype: MimeTypeArray; + new(): MimeTypeArray; +} + +interface MouseEvent extends UIEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + fromElement: Element; + layerX: number; + layerY: number; + metaKey: boolean; + movementX: number; + movementY: number; + offsetX: number; + offsetY: number; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + toElement: Element; + which: number; + x: number; + y: number; + getModifierState(keyArg: string): boolean; + initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; +} + +declare var MouseEvent: { + prototype: MouseEvent; + new(typeArg: string, eventInitDict?: MouseEventInit): MouseEvent; +} + +interface MouseWheelEvent extends MouseEvent { + wheelDelta: number; + wheelDeltaX: number; + wheelDeltaY: number; + initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; +} + +declare var MouseWheelEvent: { + prototype: MouseWheelEvent; + new(): MouseWheelEvent; +} + +interface MutationEvent extends Event { + attrChange: number; + attrName: string; + newValue: string; + prevValue: string; + relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + ADDITION: number; + MODIFICATION: number; + REMOVAL: number; +} + +declare var MutationEvent: { + prototype: MutationEvent; + new(): MutationEvent; + ADDITION: number; + MODIFICATION: number; + REMOVAL: number; +} + +interface MutationObserver { + disconnect(): void; + observe(target: Node, options: MutationObserverInit): void; + takeRecords(): MutationRecord[]; +} + +declare var MutationObserver: { + prototype: MutationObserver; + new(callback: MutationCallback): MutationObserver; +} + +interface MutationRecord { + addedNodes: NodeList; + attributeName: string; + attributeNamespace: string; + nextSibling: Node; + oldValue: string; + previousSibling: Node; + removedNodes: NodeList; + target: Node; + type: string; +} + +declare var MutationRecord: { + prototype: MutationRecord; + new(): MutationRecord; +} + +interface NamedNodeMap { + length: number; + getNamedItem(name: string): Attr; + getNamedItemNS(namespaceURI: string, localName: string): Attr; + item(index: number): Attr; + removeNamedItem(name: string): Attr; + removeNamedItemNS(namespaceURI: string, localName: string): Attr; + setNamedItem(arg: Attr): Attr; + setNamedItemNS(arg: Attr): Attr; + [index: number]: Attr; +} + +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new(): NamedNodeMap; +} + +interface NavigationCompletedEvent extends NavigationEvent { + isSuccess: boolean; + webErrorStatus: number; +} + +declare var NavigationCompletedEvent: { + prototype: NavigationCompletedEvent; + new(): NavigationCompletedEvent; +} + +interface NavigationEvent extends Event { + uri: string; +} + +declare var NavigationEvent: { + prototype: NavigationEvent; + new(): NavigationEvent; +} + +interface NavigationEventWithReferrer extends NavigationEvent { + referer: string; +} + +declare var NavigationEventWithReferrer: { + prototype: NavigationEventWithReferrer; + new(): NavigationEventWithReferrer; +} + +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver { + appCodeName: string; + appMinorVersion: string; + browserLanguage: string; + connectionSpeed: number; + cookieEnabled: boolean; + cpuClass: string; + language: string; + maxTouchPoints: number; + mimeTypes: MSMimeTypesCollection; + msManipulationViewsEnabled: boolean; + msMaxTouchPoints: number; + msPointerEnabled: boolean; + plugins: MSPluginsCollection; + pointerEnabled: boolean; + systemLanguage: string; + userLanguage: string; + webdriver: boolean; + getGamepads(): Gamepad[]; + javaEnabled(): boolean; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; + vibrate(pattern: number | number[]): boolean; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Navigator: { + prototype: Navigator; + new(): Navigator; +} + +interface Node extends EventTarget { + attributes: NamedNodeMap; + baseURI: string; + childNodes: NodeList; + firstChild: Node; + lastChild: Node; + localName: string; + namespaceURI: string; + nextSibling: Node; + nodeName: string; + nodeType: number; + nodeValue: string; + ownerDocument: Document; + parentElement: HTMLElement; + parentNode: Node; + prefix: string; + previousSibling: Node; + textContent: string; + appendChild(newChild: Node): Node; + cloneNode(deep?: boolean): Node; + compareDocumentPosition(other: Node): number; + hasAttributes(): boolean; + hasChildNodes(): boolean; + insertBefore(newChild: Node, refChild?: Node): Node; + isDefaultNamespace(namespaceURI: string): boolean; + isEqualNode(arg: Node): boolean; + isSameNode(other: Node): boolean; + lookupNamespaceURI(prefix: string): string; + lookupPrefix(namespaceURI: string): string; + normalize(): void; + removeChild(oldChild: Node): Node; + replaceChild(newChild: Node, oldChild: Node): Node; + contains(node: Node): boolean; + ATTRIBUTE_NODE: number; + CDATA_SECTION_NODE: number; + COMMENT_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + DOCUMENT_NODE: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_POSITION_PRECEDING: number; + DOCUMENT_TYPE_NODE: number; + ELEMENT_NODE: number; + ENTITY_NODE: number; + ENTITY_REFERENCE_NODE: number; + NOTATION_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + TEXT_NODE: number; +} + +declare var Node: { + prototype: Node; + new(): Node; + ATTRIBUTE_NODE: number; + CDATA_SECTION_NODE: number; + COMMENT_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + DOCUMENT_NODE: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_POSITION_PRECEDING: number; + DOCUMENT_TYPE_NODE: number; + ELEMENT_NODE: number; + ENTITY_NODE: number; + ENTITY_REFERENCE_NODE: number; + NOTATION_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + TEXT_NODE: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { + FILTER_ACCEPT: number; + FILTER_REJECT: number; + FILTER_SKIP: number; + SHOW_ALL: number; + SHOW_ATTRIBUTE: number; + SHOW_CDATA_SECTION: number; + SHOW_COMMENT: number; + SHOW_DOCUMENT: number; + SHOW_DOCUMENT_FRAGMENT: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_ELEMENT: number; + SHOW_ENTITY: number; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_PROCESSING_INSTRUCTION: number; + SHOW_TEXT: number; +} + +interface NodeIterator { + expandEntityReferences: boolean; + filter: NodeFilter; + root: Node; + whatToShow: number; + detach(): void; + nextNode(): Node; + previousNode(): Node; +} + +declare var NodeIterator: { + prototype: NodeIterator; + new(): NodeIterator; +} + +interface NodeList { + length: number; + item(index: number): Node; + [index: number]: Node; +} + +declare var NodeList: { + prototype: NodeList; + new(): NodeList; +} + +interface OES_element_index_uint { +} + +declare var OES_element_index_uint: { + prototype: OES_element_index_uint; + new(): OES_element_index_uint; +} + +interface OES_standard_derivatives { + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +declare var OES_standard_derivatives: { + prototype: OES_standard_derivatives; + new(): OES_standard_derivatives; + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +interface OES_texture_float { +} + +declare var OES_texture_float: { + prototype: OES_texture_float; + new(): OES_texture_float; +} + +interface OES_texture_float_linear { +} + +declare var OES_texture_float_linear: { + prototype: OES_texture_float_linear; + new(): OES_texture_float_linear; +} + +interface OfflineAudioCompletionEvent extends Event { + renderedBuffer: AudioBuffer; +} + +declare var OfflineAudioCompletionEvent: { + prototype: OfflineAudioCompletionEvent; + new(): OfflineAudioCompletionEvent; +} + +interface OfflineAudioContext extends AudioContext { + oncomplete: (ev: Event) => any; + startRendering(): void; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var OfflineAudioContext: { + prototype: OfflineAudioContext; + new(numberOfChannels: number, length: number, sampleRate: number): OfflineAudioContext; +} + +interface OscillatorNode extends AudioNode { + detune: AudioParam; + frequency: AudioParam; + onended: (ev: Event) => any; + type: string; + setPeriodicWave(periodicWave: PeriodicWave): void; + start(when?: number): void; + stop(when?: number): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var OscillatorNode: { + prototype: OscillatorNode; + new(): OscillatorNode; +} + +interface PageTransitionEvent extends Event { + persisted: boolean; +} + +declare var PageTransitionEvent: { + prototype: PageTransitionEvent; + new(): PageTransitionEvent; +} + +interface PannerNode extends AudioNode { + coneInnerAngle: number; + coneOuterAngle: number; + coneOuterGain: number; + distanceModel: string; + maxDistance: number; + panningModel: string; + refDistance: number; + rolloffFactor: number; + setOrientation(x: number, y: number, z: number): void; + setPosition(x: number, y: number, z: number): void; + setVelocity(x: number, y: number, z: number): void; +} + +declare var PannerNode: { + prototype: PannerNode; + new(): PannerNode; +} + +interface PerfWidgetExternal { + activeNetworkRequestCount: number; + averageFrameTime: number; + averagePaintTime: number; + extraInformationEnabled: boolean; + independentRenderingEnabled: boolean; + irDisablingContentString: string; + irStatusAvailable: boolean; + maxCpuSpeed: number; + paintRequestsPerSecond: number; + performanceCounter: number; + performanceCounterFrequency: number; + addEventListener(eventType: string, callback: Function): void; + getMemoryUsage(): number; + getProcessCpuUsage(): number; + getRecentCpuUsage(last: number): any; + getRecentFrames(last: number): any; + getRecentMemoryUsage(last: number): any; + getRecentPaintRequests(last: number): any; + removeEventListener(eventType: string, callback: Function): void; + repositionWindow(x: number, y: number): void; + resizeWindow(width: number, height: number): void; +} + +declare var PerfWidgetExternal: { + prototype: PerfWidgetExternal; + new(): PerfWidgetExternal; +} + +interface Performance { + navigation: PerformanceNavigation; + timing: PerformanceTiming; + clearMarks(markName?: string): void; + clearMeasures(measureName?: string): void; + clearResourceTimings(): void; + getEntries(): any; + getEntriesByName(name: string, entryType?: string): any; + getEntriesByType(entryType: string): any; + getMarks(markName?: string): any; + getMeasures(measureName?: string): any; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + now(): number; + setResourceTimingBufferSize(maxSize: number): void; + toJSON(): any; +} + +declare var Performance: { + prototype: Performance; + new(): Performance; +} + +interface PerformanceEntry { + duration: number; + entryType: string; + name: string; + startTime: number; +} + +declare var PerformanceEntry: { + prototype: PerformanceEntry; + new(): PerformanceEntry; +} + +interface PerformanceMark extends PerformanceEntry { +} + +declare var PerformanceMark: { + prototype: PerformanceMark; + new(): PerformanceMark; +} + +interface PerformanceMeasure extends PerformanceEntry { +} + +declare var PerformanceMeasure: { + prototype: PerformanceMeasure; + new(): PerformanceMeasure; +} + +interface PerformanceNavigation { + redirectCount: number; + type: number; + toJSON(): any; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; + TYPE_RELOAD: number; + TYPE_RESERVED: number; +} + +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; + TYPE_RELOAD: number; + TYPE_RESERVED: number; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + connectEnd: number; + connectStart: number; + domComplete: number; + domContentLoadedEventEnd: number; + domContentLoadedEventStart: number; + domInteractive: number; + domLoading: number; + domainLookupEnd: number; + domainLookupStart: number; + fetchStart: number; + loadEventEnd: number; + loadEventStart: number; + navigationStart: number; + redirectCount: number; + redirectEnd: number; + redirectStart: number; + requestStart: number; + responseEnd: number; + responseStart: number; + type: string; + unloadEventEnd: number; + unloadEventStart: number; +} + +declare var PerformanceNavigationTiming: { + prototype: PerformanceNavigationTiming; + new(): PerformanceNavigationTiming; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + connectEnd: number; + connectStart: number; + domainLookupEnd: number; + domainLookupStart: number; + fetchStart: number; + initiatorType: string; + redirectEnd: number; + redirectStart: number; + requestStart: number; + responseEnd: number; + responseStart: number; +} + +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new(): PerformanceResourceTiming; +} + +interface PerformanceTiming { + connectEnd: number; + connectStart: number; + domComplete: number; + domContentLoadedEventEnd: number; + domContentLoadedEventStart: number; + domInteractive: number; + domLoading: number; + domainLookupEnd: number; + domainLookupStart: number; + fetchStart: number; + loadEventEnd: number; + loadEventStart: number; + msFirstPaint: number; + navigationStart: number; + redirectEnd: number; + redirectStart: number; + requestStart: number; + responseEnd: number; + responseStart: number; + unloadEventEnd: number; + unloadEventStart: number; + toJSON(): any; +} + +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + +interface PeriodicWave { +} + +declare var PeriodicWave: { + prototype: PeriodicWave; + new(): PeriodicWave; +} + +interface PermissionRequest extends DeferredPermissionRequest { + state: string; + defer(): void; +} + +declare var PermissionRequest: { + prototype: PermissionRequest; + new(): PermissionRequest; +} + +interface PermissionRequestedEvent extends Event { + permissionRequest: PermissionRequest; +} + +declare var PermissionRequestedEvent: { + prototype: PermissionRequestedEvent; + new(): PermissionRequestedEvent; +} + +interface Plugin { + description: string; + filename: string; + length: number; + name: string; + version: string; + item(index: number): MimeType; + namedItem(type: string): MimeType; + [index: number]: MimeType; +} + +declare var Plugin: { + prototype: Plugin; + new(): Plugin; +} + +interface PluginArray { + length: number; + item(index: number): Plugin; + namedItem(name: string): Plugin; + refresh(reload?: boolean): void; + [index: number]: Plugin; +} + +declare var PluginArray: { + prototype: PluginArray; + new(): PluginArray; +} + +interface PointerEvent extends MouseEvent { + currentPoint: any; + height: number; + hwTimestamp: number; + intermediatePoints: any; + isPrimary: boolean; + pointerId: number; + pointerType: any; + pressure: number; + rotation: number; + tiltX: number; + tiltY: number; + width: number; + getCurrentPoint(element: Element): void; + getIntermediatePoints(element: Element): void; + initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; +} + +declare var PointerEvent: { + prototype: PointerEvent; + new(typeArg: string, eventInitDict?: PointerEventInit): PointerEvent; +} + +interface PopStateEvent extends Event { + state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} + +declare var PopStateEvent: { + prototype: PopStateEvent; + new(): PopStateEvent; +} + +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 ProcessingInstruction extends CharacterData { + target: string; +} + +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new(): ProcessingInstruction; +} + +interface ProgressEvent extends Event { + lengthComputable: boolean; + loaded: number; + total: number; + initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; +} + +declare var ProgressEvent: { + prototype: ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; +} + +interface Range { + collapsed: boolean; + commonAncestorContainer: Node; + endContainer: Node; + endOffset: number; + startContainer: Node; + startOffset: number; + cloneContents(): DocumentFragment; + cloneRange(): Range; + collapse(toStart: boolean): void; + compareBoundaryPoints(how: number, sourceRange: Range): number; + createContextualFragment(fragment: string): DocumentFragment; + deleteContents(): void; + detach(): void; + expand(Unit: string): boolean; + extractContents(): DocumentFragment; + getBoundingClientRect(): ClientRect; + getClientRects(): ClientRectList; + insertNode(newNode: Node): void; + selectNode(refNode: Node): void; + selectNodeContents(refNode: Node): void; + setEnd(refNode: Node, offset: number): void; + setEndAfter(refNode: Node): void; + setEndBefore(refNode: Node): void; + setStart(refNode: Node, offset: number): void; + setStartAfter(refNode: Node): void; + setStartBefore(refNode: Node): void; + surroundContents(newParent: Node): void; + toString(): string; + END_TO_END: number; + END_TO_START: number; + START_TO_END: number; + START_TO_START: number; +} + +declare var Range: { + prototype: Range; + new(): Range; + END_TO_END: number; + END_TO_START: number; + START_TO_END: number; + START_TO_START: number; +} + +interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { + target: SVGAnimatedString; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGAElement: { + prototype: SVGAElement; + new(): SVGAElement; +} + +interface SVGAngle { + unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; +} + +declare var SVGAngle: { + prototype: SVGAngle; + new(): SVGAngle; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; +} + +interface SVGAnimatedAngle { + animVal: SVGAngle; + baseVal: SVGAngle; +} + +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new(): SVGAnimatedAngle; +} + +interface SVGAnimatedBoolean { + animVal: boolean; + baseVal: boolean; +} + +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new(): SVGAnimatedBoolean; +} + +interface SVGAnimatedEnumeration { + animVal: number; + baseVal: number; +} + +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new(): SVGAnimatedEnumeration; +} + +interface SVGAnimatedInteger { + animVal: number; + baseVal: number; +} + +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new(): SVGAnimatedInteger; +} + +interface SVGAnimatedLength { + animVal: SVGLength; + baseVal: SVGLength; +} + +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new(): SVGAnimatedLength; +} + +interface SVGAnimatedLengthList { + animVal: SVGLengthList; + baseVal: SVGLengthList; +} + +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new(): SVGAnimatedLengthList; +} + +interface SVGAnimatedNumber { + animVal: number; + baseVal: number; +} + +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new(): SVGAnimatedNumber; +} + +interface SVGAnimatedNumberList { + animVal: SVGNumberList; + baseVal: SVGNumberList; +} + +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new(): SVGAnimatedNumberList; +} + +interface SVGAnimatedPreserveAspectRatio { + animVal: SVGPreserveAspectRatio; + baseVal: SVGPreserveAspectRatio; +} + +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new(): SVGAnimatedPreserveAspectRatio; +} + +interface SVGAnimatedRect { + animVal: SVGRect; + baseVal: SVGRect; +} + +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new(): SVGAnimatedRect; +} + +interface SVGAnimatedString { + animVal: string; + baseVal: string; +} + +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new(): SVGAnimatedString; +} + +interface SVGAnimatedTransformList { + animVal: SVGTransformList; + baseVal: SVGTransformList; +} + +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new(): SVGAnimatedTransformList; +} + +interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + cy: SVGAnimatedLength; + r: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new(): SVGCircleElement; +} + +interface SVGClipPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { + clipPathUnits: SVGAnimatedEnumeration; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new(): SVGClipPathElement; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + amplitude: SVGAnimatedNumber; + exponent: SVGAnimatedNumber; + intercept: SVGAnimatedNumber; + offset: SVGAnimatedNumber; + slope: SVGAnimatedNumber; + tableValues: SVGAnimatedNumberList; + type: SVGAnimatedEnumeration; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; +} + +declare var SVGComponentTransferFunctionElement: { + prototype: SVGComponentTransferFunctionElement; + new(): SVGComponentTransferFunctionElement; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; +} + +interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new(): SVGDefsElement; +} + +interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDescElement: { + prototype: SVGDescElement; + new(): SVGDescElement; +} + +interface SVGElement extends Element { + id: string; + onclick: (ev: MouseEvent) => any; + ondblclick: (ev: MouseEvent) => any; + onfocusin: (ev: FocusEvent) => any; + onfocusout: (ev: FocusEvent) => any; + onload: (ev: Event) => any; + onmousedown: (ev: MouseEvent) => any; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onmouseover: (ev: MouseEvent) => any; + onmouseup: (ev: MouseEvent) => any; + ownerSVGElement: SVGSVGElement; + viewportElement: SVGElement; + xmlbase: string; + className: any; + 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; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGElement: { + prototype: SVGElement; + new(): SVGElement; +} + +interface SVGElementInstance extends EventTarget { + childNodes: SVGElementInstanceList; + correspondingElement: SVGElement; + correspondingUseElement: SVGUseElement; + firstChild: SVGElementInstance; + lastChild: SVGElementInstance; + nextSibling: SVGElementInstance; + parentNode: SVGElementInstance; + previousSibling: SVGElementInstance; +} + +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new(): SVGElementInstance; +} + +interface SVGElementInstanceList { + length: number; + item(index: number): SVGElementInstance; +} + +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new(): SVGElementInstanceList; +} + +interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + cy: SVGAnimatedLength; + rx: SVGAnimatedLength; + ry: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new(): SVGEllipseElement; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + in2: SVGAnimatedString; + mode: SVGAnimatedEnumeration; + SVG_FEBLEND_MODE_COLOR: number; + SVG_FEBLEND_MODE_COLOR_BURN: number; + SVG_FEBLEND_MODE_COLOR_DODGE: number; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_DIFFERENCE: number; + SVG_FEBLEND_MODE_EXCLUSION: number; + SVG_FEBLEND_MODE_HARD_LIGHT: number; + SVG_FEBLEND_MODE_HUE: number; + SVG_FEBLEND_MODE_LIGHTEN: number; + SVG_FEBLEND_MODE_LUMINOSITY: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_OVERLAY: number; + SVG_FEBLEND_MODE_SATURATION: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_SOFT_LIGHT: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEBlendElement: { + prototype: SVGFEBlendElement; + new(): SVGFEBlendElement; + SVG_FEBLEND_MODE_COLOR: number; + SVG_FEBLEND_MODE_COLOR_BURN: number; + SVG_FEBLEND_MODE_COLOR_DODGE: number; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_DIFFERENCE: number; + SVG_FEBLEND_MODE_EXCLUSION: number; + SVG_FEBLEND_MODE_HARD_LIGHT: number; + SVG_FEBLEND_MODE_HUE: number; + SVG_FEBLEND_MODE_LIGHTEN: number; + SVG_FEBLEND_MODE_LUMINOSITY: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_OVERLAY: number; + SVG_FEBLEND_MODE_SATURATION: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_SOFT_LIGHT: number; + SVG_FEBLEND_MODE_UNKNOWN: number; +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + type: SVGAnimatedEnumeration; + values: SVGAnimatedNumberList; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEColorMatrixElement: { + prototype: SVGFEColorMatrixElement; + new(): SVGFEColorMatrixElement; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; +} + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEComponentTransferElement: { + prototype: SVGFEComponentTransferElement; + new(): SVGFEComponentTransferElement; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + in2: SVGAnimatedString; + k1: SVGAnimatedNumber; + k2: SVGAnimatedNumber; + k3: SVGAnimatedNumber; + k4: SVGAnimatedNumber; + operator: SVGAnimatedEnumeration; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFECompositeElement: { + prototype: SVGFECompositeElement; + new(): SVGFECompositeElement; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + bias: SVGAnimatedNumber; + divisor: SVGAnimatedNumber; + edgeMode: SVGAnimatedEnumeration; + in1: SVGAnimatedString; + kernelMatrix: SVGAnimatedNumberList; + kernelUnitLengthX: SVGAnimatedNumber; + kernelUnitLengthY: SVGAnimatedNumber; + orderX: SVGAnimatedInteger; + orderY: SVGAnimatedInteger; + preserveAlpha: SVGAnimatedBoolean; + targetX: SVGAnimatedInteger; + targetY: SVGAnimatedInteger; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_NONE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_WRAP: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEConvolveMatrixElement: { + prototype: SVGFEConvolveMatrixElement; + new(): SVGFEConvolveMatrixElement; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_NONE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_WRAP: number; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + diffuseConstant: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDiffuseLightingElement: { + prototype: SVGFEDiffuseLightingElement; + new(): SVGFEDiffuseLightingElement; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + in2: SVGAnimatedString; + scale: SVGAnimatedNumber; + xChannelSelector: SVGAnimatedEnumeration; + yChannelSelector: SVGAnimatedEnumeration; + SVG_CHANNEL_A: number; + SVG_CHANNEL_B: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDisplacementMapElement: { + prototype: SVGFEDisplacementMapElement; + new(): SVGFEDisplacementMapElement; + SVG_CHANNEL_A: number; + SVG_CHANNEL_B: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_UNKNOWN: number; +} + +interface SVGFEDistantLightElement extends SVGElement { + azimuth: SVGAnimatedNumber; + elevation: SVGAnimatedNumber; +} + +declare var SVGFEDistantLightElement: { + prototype: SVGFEDistantLightElement; + new(): SVGFEDistantLightElement; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFloodElement: { + prototype: SVGFEFloodElement; + new(): SVGFEFloodElement; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { +} + +declare var SVGFEFuncAElement: { + prototype: SVGFEFuncAElement; + new(): SVGFEFuncAElement; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { +} + +declare var SVGFEFuncBElement: { + prototype: SVGFEFuncBElement; + new(): SVGFEFuncBElement; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { +} + +declare var SVGFEFuncGElement: { + prototype: SVGFEFuncGElement; + new(): SVGFEFuncGElement; +} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { +} + +declare var SVGFEFuncRElement: { + prototype: SVGFEFuncRElement; + new(): SVGFEFuncRElement; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + stdDeviationX: SVGAnimatedNumber; + stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEGaussianBlurElement: { + prototype: SVGFEGaussianBlurElement; + new(): SVGFEGaussianBlurElement; +} + +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEImageElement: { + prototype: SVGFEImageElement; + new(): SVGFEImageElement; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMergeElement: { + prototype: SVGFEMergeElement; + new(): SVGFEMergeElement; +} + +interface SVGFEMergeNodeElement extends SVGElement { + in1: SVGAnimatedString; +} + +declare var SVGFEMergeNodeElement: { + prototype: SVGFEMergeNodeElement; + new(): SVGFEMergeNodeElement; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + operator: SVGAnimatedEnumeration; + radiusX: SVGAnimatedNumber; + radiusY: SVGAnimatedNumber; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMorphologyElement: { + prototype: SVGFEMorphologyElement; + new(): SVGFEMorphologyElement; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + dx: SVGAnimatedNumber; + dy: SVGAnimatedNumber; + in1: SVGAnimatedString; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEOffsetElement: { + prototype: SVGFEOffsetElement; + new(): SVGFEOffsetElement; +} + +interface SVGFEPointLightElement extends SVGElement { + x: SVGAnimatedNumber; + y: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} + +declare var SVGFEPointLightElement: { + prototype: SVGFEPointLightElement; + new(): SVGFEPointLightElement; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + kernelUnitLengthY: SVGAnimatedNumber; + specularConstant: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFESpecularLightingElement: { + prototype: SVGFESpecularLightingElement; + new(): SVGFESpecularLightingElement; +} + +interface SVGFESpotLightElement extends SVGElement { + limitingConeAngle: SVGAnimatedNumber; + pointsAtX: SVGAnimatedNumber; + pointsAtY: SVGAnimatedNumber; + pointsAtZ: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + x: SVGAnimatedNumber; + y: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} + +declare var SVGFESpotLightElement: { + prototype: SVGFESpotLightElement; + new(): SVGFESpotLightElement; +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETileElement: { + prototype: SVGFETileElement; + new(): SVGFETileElement; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + baseFrequencyX: SVGAnimatedNumber; + baseFrequencyY: SVGAnimatedNumber; + numOctaves: SVGAnimatedInteger; + seed: SVGAnimatedNumber; + stitchTiles: SVGAnimatedEnumeration; + type: SVGAnimatedEnumeration; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_STITCHTYPE_STITCH: number; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETurbulenceElement: { + prototype: SVGFETurbulenceElement; + new(): SVGFETurbulenceElement; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_STITCHTYPE_STITCH: number; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + filterResX: SVGAnimatedInteger; + filterResY: SVGAnimatedInteger; + filterUnits: SVGAnimatedEnumeration; + height: SVGAnimatedLength; + primitiveUnits: SVGAnimatedEnumeration; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + setFilterRes(filterResX: number, filterResY: number): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFilterElement: { + prototype: SVGFilterElement; + new(): SVGFilterElement; +} + +interface SVGForeignObjectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + height: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGForeignObjectElement: { + prototype: SVGForeignObjectElement; + new(): SVGForeignObjectElement; +} + +interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGElement: { + prototype: SVGGElement; + new(): SVGGElement; +} + +interface SVGGradientElement extends SVGElement, SVGStylable, SVGExternalResourcesRequired, SVGURIReference, SVGUnitTypes { + gradientTransform: SVGAnimatedTransformList; + gradientUnits: SVGAnimatedEnumeration; + spreadMethod: SVGAnimatedEnumeration; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_REPEAT: number; + SVG_SPREADMETHOD_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new(): SVGGradientElement; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_REPEAT: number; + SVG_SPREADMETHOD_UNKNOWN: number; +} + +interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { + height: SVGAnimatedLength; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGImageElement: { + prototype: SVGImageElement; + new(): SVGImageElement; +} + +interface SVGLength { + unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_EXS: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; +} + +declare var SVGLength: { + prototype: SVGLength; + new(): SVGLength; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_EXS: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; +} + +interface SVGLengthList { + numberOfItems: number; + appendItem(newItem: SVGLength): SVGLength; + clear(): void; + getItem(index: number): SVGLength; + initialize(newItem: SVGLength): SVGLength; + insertItemBefore(newItem: SVGLength, index: number): SVGLength; + removeItem(index: number): SVGLength; + replaceItem(newItem: SVGLength, index: number): SVGLength; +} + +declare var SVGLengthList: { + prototype: SVGLengthList; + new(): SVGLengthList; +} + +interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + x1: SVGAnimatedLength; + x2: SVGAnimatedLength; + y1: SVGAnimatedLength; + y2: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGLineElement: { + prototype: SVGLineElement; + new(): SVGLineElement; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + x1: SVGAnimatedLength; + x2: SVGAnimatedLength; + y1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} + +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new(): SVGLinearGradientElement; +} + +interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { + markerHeight: SVGAnimatedLength; + markerUnits: SVGAnimatedEnumeration; + markerWidth: SVGAnimatedLength; + orientAngle: SVGAnimatedAngle; + orientType: SVGAnimatedEnumeration; + refX: SVGAnimatedLength; + refY: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKER_ORIENT_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new(): SVGMarkerElement; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKER_ORIENT_UNKNOWN: number; +} + +interface SVGMaskElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGUnitTypes { + height: SVGAnimatedLength; + maskContentUnits: SVGAnimatedEnumeration; + maskUnits: SVGAnimatedEnumeration; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMaskElement: { + prototype: SVGMaskElement; + new(): SVGMaskElement; +} + +interface SVGMatrix { + a: number; + b: number; + c: number; + d: number; + e: number; + f: number; + flipX(): SVGMatrix; + flipY(): SVGMatrix; + inverse(): SVGMatrix; + multiply(secondMatrix: SVGMatrix): SVGMatrix; + rotate(angle: number): SVGMatrix; + rotateFromVector(x: number, y: number): SVGMatrix; + scale(scaleFactor: number): SVGMatrix; + scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; + skewX(angle: number): SVGMatrix; + skewY(angle: number): SVGMatrix; + translate(x: number, y: number): SVGMatrix; +} + +declare var SVGMatrix: { + prototype: SVGMatrix; + new(): SVGMatrix; +} + +interface SVGMetadataElement extends SVGElement { +} + +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new(): SVGMetadataElement; +} + +interface SVGNumber { + value: number; +} + +declare var SVGNumber: { + prototype: SVGNumber; + new(): SVGNumber; +} + +interface SVGNumberList { + numberOfItems: number; + appendItem(newItem: SVGNumber): SVGNumber; + clear(): void; + getItem(index: number): SVGNumber; + initialize(newItem: SVGNumber): SVGNumber; + insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; + removeItem(index: number): SVGNumber; + replaceItem(newItem: SVGNumber, index: number): SVGNumber; +} + +declare var SVGNumberList: { + prototype: SVGNumberList; + new(): SVGNumberList; +} + +interface SVGPathElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPathData { + createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; + createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; + createSVGPathSegClosePath(): SVGPathSegClosePath; + createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; + createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; + createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; + createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; + createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; + createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; + createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; + createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; + createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; + createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; + createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; + createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; + createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; + createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; + createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; + createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; + getPathSegAtLength(distance: number): number; + getPointAtLength(distance: number): SVGPoint; + getTotalLength(): number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPathElement: { + prototype: SVGPathElement; + new(): SVGPathElement; +} + +interface SVGPathSeg { + pathSegType: number; + pathSegTypeAsLetter: string; + PATHSEG_ARC_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_MOVETO_REL: number; + PATHSEG_UNKNOWN: number; +} + +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new(): SVGPathSeg; + PATHSEG_ARC_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_MOVETO_REL: number; + PATHSEG_UNKNOWN: number; +} + +interface SVGPathSegArcAbs extends SVGPathSeg { + angle: number; + largeArcFlag: boolean; + r1: number; + r2: number; + sweepFlag: boolean; + x: number; + y: number; +} + +declare var SVGPathSegArcAbs: { + prototype: SVGPathSegArcAbs; + new(): SVGPathSegArcAbs; +} + +interface SVGPathSegArcRel extends SVGPathSeg { + angle: number; + largeArcFlag: boolean; + r1: number; + r2: number; + sweepFlag: boolean; + x: number; + y: number; +} + +declare var SVGPathSegArcRel: { + prototype: SVGPathSegArcRel; + new(): SVGPathSegArcRel; +} + +interface SVGPathSegClosePath extends SVGPathSeg { +} + +declare var SVGPathSegClosePath: { + prototype: SVGPathSegClosePath; + new(): SVGPathSegClosePath; +} + +interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + x: number; + x1: number; + x2: number; + y: number; + y1: number; + y2: number; +} + +declare var SVGPathSegCurvetoCubicAbs: { + prototype: SVGPathSegCurvetoCubicAbs; + new(): SVGPathSegCurvetoCubicAbs; +} + +interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { + x: number; + x1: number; + x2: number; + y: number; + y1: number; + y2: number; +} + +declare var SVGPathSegCurvetoCubicRel: { + prototype: SVGPathSegCurvetoCubicRel; + new(): SVGPathSegCurvetoCubicRel; +} + +interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + x: number; + x2: number; + y: number; + y2: number; +} + +declare var SVGPathSegCurvetoCubicSmoothAbs: { + prototype: SVGPathSegCurvetoCubicSmoothAbs; + new(): SVGPathSegCurvetoCubicSmoothAbs; +} + +interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + x: number; + x2: number; + y: number; + y2: number; +} + +declare var SVGPathSegCurvetoCubicSmoothRel: { + prototype: SVGPathSegCurvetoCubicSmoothRel; + new(): SVGPathSegCurvetoCubicSmoothRel; +} + +interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + x: number; + x1: number; + y: number; + y1: number; +} + +declare var SVGPathSegCurvetoQuadraticAbs: { + prototype: SVGPathSegCurvetoQuadraticAbs; + new(): SVGPathSegCurvetoQuadraticAbs; +} + +interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + x: number; + x1: number; + y: number; + y1: number; +} + +declare var SVGPathSegCurvetoQuadraticRel: { + prototype: SVGPathSegCurvetoQuadraticRel; + new(): SVGPathSegCurvetoQuadraticRel; +} + +interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegCurvetoQuadraticSmoothAbs: { + prototype: SVGPathSegCurvetoQuadraticSmoothAbs; + new(): SVGPathSegCurvetoQuadraticSmoothAbs; +} + +interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegCurvetoQuadraticSmoothRel: { + prototype: SVGPathSegCurvetoQuadraticSmoothRel; + new(): SVGPathSegCurvetoQuadraticSmoothRel; +} + +interface SVGPathSegLinetoAbs extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegLinetoAbs: { + prototype: SVGPathSegLinetoAbs; + new(): SVGPathSegLinetoAbs; +} + +interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + x: number; +} + +declare var SVGPathSegLinetoHorizontalAbs: { + prototype: SVGPathSegLinetoHorizontalAbs; + new(): SVGPathSegLinetoHorizontalAbs; +} + +interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + x: number; +} + +declare var SVGPathSegLinetoHorizontalRel: { + prototype: SVGPathSegLinetoHorizontalRel; + new(): SVGPathSegLinetoHorizontalRel; +} + +interface SVGPathSegLinetoRel extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegLinetoRel: { + prototype: SVGPathSegLinetoRel; + new(): SVGPathSegLinetoRel; +} + +interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + y: number; +} + +declare var SVGPathSegLinetoVerticalAbs: { + prototype: SVGPathSegLinetoVerticalAbs; + new(): SVGPathSegLinetoVerticalAbs; +} + +interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { + y: number; +} + +declare var SVGPathSegLinetoVerticalRel: { + prototype: SVGPathSegLinetoVerticalRel; + new(): SVGPathSegLinetoVerticalRel; +} + +interface SVGPathSegList { + numberOfItems: number; + appendItem(newItem: SVGPathSeg): SVGPathSeg; + clear(): void; + getItem(index: number): SVGPathSeg; + initialize(newItem: SVGPathSeg): SVGPathSeg; + insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; + removeItem(index: number): SVGPathSeg; + replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; +} + +declare var SVGPathSegList: { + prototype: SVGPathSegList; + new(): SVGPathSegList; +} + +interface SVGPathSegMovetoAbs extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegMovetoAbs: { + prototype: SVGPathSegMovetoAbs; + new(): SVGPathSegMovetoAbs; +} + +interface SVGPathSegMovetoRel extends SVGPathSeg { + x: number; + y: number; +} + +declare var SVGPathSegMovetoRel: { + prototype: SVGPathSegMovetoRel; + new(): SVGPathSegMovetoRel; +} + +interface SVGPatternElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGURIReference, SVGUnitTypes { + height: SVGAnimatedLength; + patternContentUnits: SVGAnimatedEnumeration; + patternTransform: SVGAnimatedTransformList; + patternUnits: SVGAnimatedEnumeration; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPatternElement: { + prototype: SVGPatternElement; + new(): SVGPatternElement; +} + +interface SVGPoint { + x: number; + y: number; + matrixTransform(matrix: SVGMatrix): SVGPoint; +} + +declare var SVGPoint: { + prototype: SVGPoint; + new(): SVGPoint; +} + +interface SVGPointList { + numberOfItems: number; + appendItem(newItem: SVGPoint): SVGPoint; + clear(): void; + getItem(index: number): SVGPoint; + initialize(newItem: SVGPoint): SVGPoint; + insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; + removeItem(index: number): SVGPoint; + replaceItem(newItem: SVGPoint, index: number): SVGPoint; +} + +declare var SVGPointList: { + prototype: SVGPointList; + new(): SVGPointList; +} + +interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new(): SVGPolygonElement; +} + +interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGAnimatedPoints { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new(): SVGPolylineElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + SVG_MEETORSLICE_MEET: number; + SVG_MEETORSLICE_SLICE: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new(): SVGPreserveAspectRatio; + SVG_MEETORSLICE_MEET: number; + SVG_MEETORSLICE_SLICE: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + cx: SVGAnimatedLength; + cy: SVGAnimatedLength; + fx: SVGAnimatedLength; + fy: SVGAnimatedLength; + r: SVGAnimatedLength; +} + +declare var SVGRadialGradientElement: { + prototype: SVGRadialGradientElement; + new(): SVGRadialGradientElement; +} + +interface SVGRect { + height: number; + width: number; + x: number; + y: number; +} + +declare var SVGRect: { + prototype: SVGRect; + new(): SVGRect; +} + +interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + height: SVGAnimatedLength; + rx: SVGAnimatedLength; + ry: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGRectElement: { + prototype: SVGRectElement; + new(): SVGRectElement; +} + +interface SVGSVGElement extends SVGElement, DocumentEvent, SVGLocatable, SVGTests, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { + contentScriptType: string; + contentStyleType: string; + currentScale: number; + currentTranslate: SVGPoint; + height: SVGAnimatedLength; + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + onscroll: (ev: UIEvent) => any; + onunload: (ev: Event) => any; + onzoom: (ev: SVGZoomEvent) => any; + pixelUnitToMillimeterX: number; + pixelUnitToMillimeterY: number; + screenPixelToMillimeterX: number; + screenPixelToMillimeterY: number; + viewport: SVGRect; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + checkEnclosure(element: SVGElement, rect: SVGRect): boolean; + checkIntersection(element: SVGElement, rect: SVGRect): boolean; + createSVGAngle(): SVGAngle; + createSVGLength(): SVGLength; + createSVGMatrix(): SVGMatrix; + createSVGNumber(): SVGNumber; + createSVGPoint(): SVGPoint; + createSVGRect(): SVGRect; + createSVGTransform(): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + deselectAll(): void; + forceRedraw(): void; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getCurrentTime(): number; + getElementById(elementId: string): Element; + getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; + pauseAnimations(): void; + setCurrentTime(seconds: number): void; + suspendRedraw(maxWaitMilliseconds: number): number; + unpauseAnimations(): void; + unsuspendRedraw(suspendHandleID: number): void; + unsuspendRedrawAll(): void; + 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; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGotPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSLostPointerCapture", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "SVGAbort", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "SVGError", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "SVGUnload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "SVGZoom", listener: (ev: SVGZoomEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ariarequest", listener: (ev: AriaRequestEvent) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "command", listener: (ev: CommandEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchcancel", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchend", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchmove", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "touchstart", listener: (ev: TouchEvent) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "webkitfullscreenerror", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new(): SVGSVGElement; +} + +interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { + type: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new(): SVGScriptElement; +} + +interface SVGStopElement extends SVGElement, SVGStylable { + offset: SVGAnimatedNumber; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStopElement: { + prototype: SVGStopElement; + new(): SVGStopElement; +} + +interface SVGStringList { + numberOfItems: number; + appendItem(newItem: string): string; + clear(): void; + getItem(index: number): string; + initialize(newItem: string): string; + insertItemBefore(newItem: string, index: number): string; + removeItem(index: number): string; + replaceItem(newItem: string, index: number): string; +} + +declare var SVGStringList: { + prototype: SVGStringList; + new(): SVGStringList; +} + +interface SVGStyleElement extends SVGElement, SVGLangSpace { + media: string; + title: string; + type: string; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new(): SVGStyleElement; +} + +interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new(): SVGSwitchElement; +} + +interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGExternalResourcesRequired, SVGFitToViewBox { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new(): SVGSymbolElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { +} + +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new(): SVGTSpanElement; +} + +interface SVGTextContentElement extends SVGElement, SVGStylable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired { + lengthAdjust: SVGAnimatedEnumeration; + textLength: SVGAnimatedLength; + getCharNumAtPosition(point: SVGPoint): number; + getComputedTextLength(): number; + getEndPositionOfChar(charnum: number): SVGPoint; + getExtentOfChar(charnum: number): SVGRect; + getNumberOfChars(): number; + getRotationOfChar(charnum: number): number; + getStartPositionOfChar(charnum: number): SVGPoint; + getSubStringLength(charnum: number, nchars: number): number; + selectSubString(charnum: number, nchars: number): void; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new(): SVGTextContentElement; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} + +interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextElement: { + prototype: SVGTextElement; + new(): SVGTextElement; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + method: SVGAnimatedEnumeration; + spacing: SVGAnimatedEnumeration; + startOffset: SVGAnimatedLength; + TEXTPATH_METHODTYPE_ALIGN: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new(): SVGTextPathElement; + TEXTPATH_METHODTYPE_ALIGN: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + dx: SVGAnimatedLengthList; + dy: SVGAnimatedLengthList; + rotate: SVGAnimatedNumberList; + x: SVGAnimatedLengthList; + y: SVGAnimatedLengthList; +} + +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new(): SVGTextPositioningElement; +} + +interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new(): SVGTitleElement; +} + +interface SVGTransform { + angle: number; + matrix: SVGMatrix; + type: number; + setMatrix(matrix: SVGMatrix): void; + setRotate(angle: number, cx: number, cy: number): void; + setScale(sx: number, sy: number): void; + setSkewX(angle: number): void; + setSkewY(angle: number): void; + setTranslate(tx: number, ty: number): void; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_SKEWY: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_UNKNOWN: number; +} + +declare var SVGTransform: { + prototype: SVGTransform; + new(): SVGTransform; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_SKEWY: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_UNKNOWN: number; +} + +interface SVGTransformList { + numberOfItems: number; + appendItem(newItem: SVGTransform): SVGTransform; + clear(): void; + consolidate(): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + getItem(index: number): SVGTransform; + initialize(newItem: SVGTransform): SVGTransform; + insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; + removeItem(index: number): SVGTransform; + replaceItem(newItem: SVGTransform, index: number): SVGTransform; +} + +declare var SVGTransformList: { + prototype: SVGTransformList; + new(): SVGTransformList; +} + +interface SVGUnitTypes { + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: SVGUnitTypes; + +interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGURIReference { + animatedInstanceRoot: SVGElementInstance; + height: SVGAnimatedLength; + instanceRoot: SVGElementInstance; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGUseElement: { + prototype: SVGUseElement; + new(): SVGUseElement; +} + +interface SVGViewElement extends SVGElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan { + viewTarget: SVGStringList; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGViewElement: { + prototype: SVGViewElement; + new(): SVGViewElement; +} + +interface SVGZoomAndPan { + zoomAndPan: number; +} + +declare var SVGZoomAndPan: { + SVG_ZOOMANDPAN_DISABLE: number; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; +} + +interface SVGZoomEvent extends UIEvent { + newScale: number; + newTranslate: SVGPoint; + previousScale: number; + previousTranslate: SVGPoint; + zoomRectScreen: SVGRect; +} + +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new(): SVGZoomEvent; +} + +interface Screen extends EventTarget { + availHeight: number; + availWidth: number; + bufferDepth: number; + colorDepth: number; + deviceXDPI: number; + deviceYDPI: number; + fontSmoothingEnabled: boolean; + height: number; + logicalXDPI: number; + logicalYDPI: number; + msOrientation: string; + onmsorientationchange: (ev: Event) => any; + pixelDepth: number; + systemXDPI: number; + systemYDPI: number; + width: number; + msLockOrientation(orientations: string | string[]): boolean; + msUnlockOrientation(): void; + addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Screen: { + prototype: Screen; + new(): Screen; +} + +interface ScriptNotifyEvent extends Event { + callingUri: string; + value: string; +} + +declare var ScriptNotifyEvent: { + prototype: ScriptNotifyEvent; + new(): ScriptNotifyEvent; +} + +interface ScriptProcessorNode extends AudioNode { + bufferSize: number; + onaudioprocess: (ev: AudioProcessingEvent) => any; + addEventListener(type: "audioprocess", listener: (ev: AudioProcessingEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ScriptProcessorNode: { + prototype: ScriptProcessorNode; + new(): ScriptProcessorNode; +} + +interface Selection { + anchorNode: Node; + anchorOffset: number; + focusNode: Node; + focusOffset: number; + isCollapsed: boolean; + rangeCount: number; + type: string; + addRange(range: Range): void; + collapse(parentNode: Node, offset: number): void; + collapseToEnd(): void; + collapseToStart(): void; + containsNode(node: Node, partlyContained: boolean): boolean; + deleteFromDocument(): void; + empty(): void; + extend(newNode: Node, offset: number): void; + getRangeAt(index: number): Range; + removeAllRanges(): void; + removeRange(range: Range): void; + selectAllChildren(parentNode: Node): void; + setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; + toString(): string; +} + +declare var Selection: { + prototype: Selection; + new(): Selection; +} + +interface SourceBuffer extends EventTarget { + appendWindowEnd: number; + appendWindowStart: number; + audioTracks: AudioTrackList; + buffered: TimeRanges; + mode: string; + timestampOffset: number; + updating: boolean; + videoTracks: VideoTrackList; + abort(): void; + appendBuffer(data: ArrayBuffer | ArrayBufferView): void; + appendStream(stream: MSStream, maxSize?: number): void; + remove(start: number, end: number): void; +} + +declare var SourceBuffer: { + prototype: SourceBuffer; + new(): SourceBuffer; +} + +interface SourceBufferList extends EventTarget { + length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} + +declare var SourceBufferList: { + prototype: SourceBufferList; + new(): SourceBufferList; +} + +interface StereoPannerNode extends AudioNode { + pan: AudioParam; +} + +declare var StereoPannerNode: { + prototype: StereoPannerNode; + new(): StereoPannerNode; +} + +interface Storage { + length: number; + clear(): void; + getItem(key: string): any; + key(index: number): string; + removeItem(key: string): void; + setItem(key: string, data: string): void; + [key: string]: any; + [index: number]: string; +} + +declare var Storage: { + prototype: Storage; + new(): Storage; +} + +interface StorageEvent extends Event { + url: string; + key?: string; + oldValue?: string; + newValue?: string; + storageArea?: Storage; +} + +declare var StorageEvent: { + prototype: StorageEvent; + new (type: string, eventInitDict?: StorageEventInit): StorageEvent; +} + +interface StyleMedia { + type: string; + matchMedium(mediaquery: string): boolean; +} + +declare var StyleMedia: { + prototype: StyleMedia; + new(): StyleMedia; +} + +interface StyleSheet { + disabled: boolean; + href: string; + media: MediaList; + ownerNode: Node; + parentStyleSheet: StyleSheet; + title: string; + type: string; +} + +declare var StyleSheet: { + prototype: StyleSheet; + new(): StyleSheet; +} + +interface StyleSheetList { + length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} + +declare var StyleSheetList: { + prototype: StyleSheetList; + new(): StyleSheetList; +} + +interface StyleSheetPageList { + length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} + +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new(): StyleSheetPageList; +} + +interface SubtleCrypto { + decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any; + deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + digest(algorithm: string | Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + exportKey(format: string, key: CryptoKey): any; + generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any; +} + +declare var SubtleCrypto: { + prototype: SubtleCrypto; + new(): SubtleCrypto; +} + +interface Text extends CharacterData { + wholeText: string; + replaceWholeText(content: string): Text; + splitText(offset: number): Text; +} + +declare var Text: { + prototype: Text; + new(): Text; +} + +interface TextEvent extends UIEvent { + data: string; + inputMethod: number; + locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_MULTIMODAL: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_VOICE: number; +} + +declare var TextEvent: { + prototype: TextEvent; + new(): TextEvent; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_MULTIMODAL: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_VOICE: number; +} + +interface TextMetrics { + width: number; +} + +declare var TextMetrics: { + prototype: TextMetrics; + new(): TextMetrics; +} + +interface TextRange { + boundingHeight: number; + boundingLeft: number; + boundingTop: number; + boundingWidth: number; + htmlText: string; + offsetLeft: number; + offsetTop: number; + text: string; + collapse(start?: boolean): void; + compareEndPoints(how: string, sourceRange: TextRange): number; + duplicate(): TextRange; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + execCommandShowHelp(cmdID: string): boolean; + expand(Unit: string): boolean; + findText(string: string, count?: number, flags?: number): boolean; + getBookmark(): string; + getBoundingClientRect(): ClientRect; + getClientRects(): ClientRectList; + inRange(range: TextRange): boolean; + isEqual(range: TextRange): boolean; + move(unit: string, count?: number): number; + moveEnd(unit: string, count?: number): number; + moveStart(unit: string, count?: number): number; + moveToBookmark(bookmark: string): boolean; + moveToElementText(element: Element): void; + moveToPoint(x: number, y: number): void; + parentElement(): Element; + pasteHTML(html: string): void; + queryCommandEnabled(cmdID: string): boolean; + queryCommandIndeterm(cmdID: string): boolean; + queryCommandState(cmdID: string): boolean; + queryCommandSupported(cmdID: string): boolean; + queryCommandText(cmdID: string): string; + queryCommandValue(cmdID: string): any; + scrollIntoView(fStart?: boolean): void; + select(): void; + setEndPoint(how: string, SourceRange: TextRange): void; +} + +declare var TextRange: { + prototype: TextRange; + new(): TextRange; +} + +interface TextRangeCollection { + length: number; + item(index: number): TextRange; + [index: number]: TextRange; +} + +declare var TextRangeCollection: { + prototype: TextRangeCollection; + new(): TextRangeCollection; +} + +interface TextTrack extends EventTarget { + activeCues: TextTrackCueList; + cues: TextTrackCueList; + inBandMetadataTrackDispatchType: string; + kind: string; + label: string; + language: string; + mode: any; + oncuechange: (ev: Event) => any; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + readyState: number; + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; + DISABLED: number; + ERROR: number; + HIDDEN: number; + LOADED: number; + LOADING: number; + NONE: number; + SHOWING: number; + addEventListener(type: "cuechange", 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: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var TextTrack: { + prototype: TextTrack; + new(): TextTrack; + DISABLED: number; + ERROR: number; + HIDDEN: number; + LOADED: number; + LOADING: number; + NONE: number; + SHOWING: number; +} + +interface TextTrackCue extends EventTarget { + endTime: number; + id: string; + onenter: (ev: Event) => any; + onexit: (ev: Event) => any; + pauseOnExit: boolean; + startTime: number; + text: string; + track: TextTrack; + getCueAsHTML(): DocumentFragment; + addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var TextTrackCue: { + prototype: TextTrackCue; + new(startTime: number, endTime: number, text: string): TextTrackCue; +} + +interface TextTrackCueList { + length: number; + getCueById(id: string): TextTrackCue; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; +} + +declare var TextTrackCueList: { + prototype: TextTrackCueList; + new(): TextTrackCueList; +} + +interface TextTrackList extends EventTarget { + length: number; + onaddtrack: (ev: TrackEvent) => any; + item(index: number): TextTrack; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: TextTrack; +} + +declare var TextTrackList: { + prototype: TextTrackList; + new(): TextTrackList; +} + +interface TimeRanges { + length: number; + end(index: number): number; + start(index: number): number; +} + +declare var TimeRanges: { + prototype: TimeRanges; + new(): TimeRanges; +} + +interface Touch { + clientX: number; + clientY: number; + identifier: number; + pageX: number; + pageY: number; + screenX: number; + screenY: number; + target: EventTarget; +} + +declare var Touch: { + prototype: Touch; + new(): Touch; +} + +interface TouchEvent extends UIEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; +} + +declare var TouchEvent: { + prototype: TouchEvent; + new(): TouchEvent; +} + +interface TouchList { + length: number; + item(index: number): Touch; + [index: number]: Touch; +} + +declare var TouchList: { + prototype: TouchList; + new(): TouchList; +} + +interface TrackEvent extends Event { + track: any; +} + +declare var TrackEvent: { + prototype: TrackEvent; + new(): TrackEvent; +} + +interface TransitionEvent extends Event { + elapsedTime: number; + propertyName: string; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} + +declare var TransitionEvent: { + prototype: TransitionEvent; + new(): TransitionEvent; +} + +interface TreeWalker { + currentNode: Node; + expandEntityReferences: boolean; + filter: NodeFilter; + root: Node; + whatToShow: number; + firstChild(): Node; + lastChild(): Node; + nextNode(): Node; + nextSibling(): Node; + parentNode(): Node; + previousNode(): Node; + previousSibling(): Node; +} + +declare var TreeWalker: { + prototype: TreeWalker; + new(): TreeWalker; +} + +interface UIEvent extends Event { + detail: number; + view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} + +declare var UIEvent: { + prototype: UIEvent; + new(type: string, eventInitDict?: UIEventInit): UIEvent; +} + +interface URL { + createObjectURL(object: any, options?: ObjectURLOptions): string; + revokeObjectURL(url: string): void; +} +declare var URL: URL; + +interface UnviewableContentIdentifiedEvent extends NavigationEventWithReferrer { + mediaType: string; +} + +declare var UnviewableContentIdentifiedEvent: { + prototype: UnviewableContentIdentifiedEvent; + new(): UnviewableContentIdentifiedEvent; +} + +interface ValidityState { + badInput: boolean; + customError: boolean; + patternMismatch: boolean; + rangeOverflow: boolean; + rangeUnderflow: boolean; + stepMismatch: boolean; + tooLong: boolean; + typeMismatch: boolean; + valid: boolean; + valueMissing: boolean; +} + +declare var ValidityState: { + prototype: ValidityState; + new(): ValidityState; +} + +interface VideoPlaybackQuality { + corruptedVideoFrames: number; + creationTime: number; + droppedVideoFrames: number; + totalFrameDelay: number; + totalVideoFrames: number; +} + +declare var VideoPlaybackQuality: { + prototype: VideoPlaybackQuality; + new(): VideoPlaybackQuality; +} + +interface VideoTrack { + id: string; + kind: string; + label: string; + language: string; + selected: boolean; + sourceBuffer: SourceBuffer; +} + +declare var VideoTrack: { + prototype: VideoTrack; + new(): VideoTrack; +} + +interface VideoTrackList extends EventTarget { + length: number; + onaddtrack: (ev: TrackEvent) => any; + onchange: (ev: Event) => any; + onremovetrack: (ev: TrackEvent) => any; + selectedIndex: number; + getTrackById(id: string): VideoTrack; + item(index: number): VideoTrack; + addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "removetrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: VideoTrack; +} + +declare var VideoTrackList: { + prototype: VideoTrackList; + new(): VideoTrackList; +} + +interface WEBGL_compressed_texture_s3tc { + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +declare var WEBGL_compressed_texture_s3tc: { + prototype: WEBGL_compressed_texture_s3tc; + new(): WEBGL_compressed_texture_s3tc; + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +interface WEBGL_debug_renderer_info { + UNMASKED_RENDERER_WEBGL: number; + UNMASKED_VENDOR_WEBGL: number; +} + +declare var WEBGL_debug_renderer_info: { + prototype: WEBGL_debug_renderer_info; + new(): WEBGL_debug_renderer_info; + UNMASKED_RENDERER_WEBGL: number; + UNMASKED_VENDOR_WEBGL: number; +} + +interface WEBGL_depth_texture { + UNSIGNED_INT_24_8_WEBGL: number; +} + +declare var WEBGL_depth_texture: { + prototype: WEBGL_depth_texture; + new(): WEBGL_depth_texture; + UNSIGNED_INT_24_8_WEBGL: number; +} + +interface WaveShaperNode extends AudioNode { + curve: Float32Array; + oversample: string; +} + +declare var WaveShaperNode: { + prototype: WaveShaperNode; + new(): WaveShaperNode; +} + +interface WebGLActiveInfo { + name: string; + size: number; + type: number; +} + +declare var WebGLActiveInfo: { + prototype: WebGLActiveInfo; + new(): WebGLActiveInfo; +} + +interface WebGLBuffer extends WebGLObject { +} + +declare var WebGLBuffer: { + prototype: WebGLBuffer; + new(): WebGLBuffer; +} + +interface WebGLContextEvent extends Event { + statusMessage: string; +} + +declare var WebGLContextEvent: { + prototype: WebGLContextEvent; + new(): WebGLContextEvent; +} + +interface WebGLFramebuffer extends WebGLObject { +} + +declare var WebGLFramebuffer: { + prototype: WebGLFramebuffer; + new(): WebGLFramebuffer; +} + +interface WebGLObject { +} + +declare var WebGLObject: { + prototype: WebGLObject; + new(): WebGLObject; +} + +interface WebGLProgram extends WebGLObject { +} + +declare var WebGLProgram: { + prototype: WebGLProgram; + new(): WebGLProgram; +} + +interface WebGLRenderbuffer extends WebGLObject { +} + +declare var WebGLRenderbuffer: { + prototype: WebGLRenderbuffer; + new(): WebGLRenderbuffer; +} + +interface WebGLRenderingContext { + canvas: HTMLCanvasElement; + drawingBufferHeight: number; + drawingBufferWidth: number; + activeTexture(texture: number): void; + attachShader(program: WebGLProgram, shader: WebGLShader): void; + bindAttribLocation(program: WebGLProgram, index: number, name: string): void; + bindBuffer(target: number, buffer: WebGLBuffer): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer): void; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer): void; + bindTexture(target: number, texture: WebGLTexture): void; + blendColor(red: number, green: number, blue: number, alpha: number): void; + blendEquation(mode: number): void; + blendEquationSeparate(modeRGB: number, modeAlpha: number): void; + blendFunc(sfactor: number, dfactor: number): void; + blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; + bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void; + checkFramebufferStatus(target: number): number; + clear(mask: number): void; + clearColor(red: number, green: number, blue: number, alpha: number): void; + clearDepth(depth: number): void; + clearStencil(s: number): void; + colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; + compileShader(shader: WebGLShader): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; + copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; + copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; + createBuffer(): WebGLBuffer; + createFramebuffer(): WebGLFramebuffer; + createProgram(): WebGLProgram; + createRenderbuffer(): WebGLRenderbuffer; + createShader(type: number): WebGLShader; + createTexture(): WebGLTexture; + cullFace(mode: number): void; + deleteBuffer(buffer: WebGLBuffer): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer): void; + deleteProgram(program: WebGLProgram): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer): void; + deleteShader(shader: WebGLShader): void; + deleteTexture(texture: WebGLTexture): void; + depthFunc(func: number): void; + depthMask(flag: boolean): void; + depthRange(zNear: number, zFar: number): void; + detachShader(program: WebGLProgram, shader: WebGLShader): void; + disable(cap: number): void; + disableVertexAttribArray(index: number): void; + drawArrays(mode: number, first: number, count: number): void; + drawElements(mode: number, count: number, type: number, offset: number): void; + enable(cap: number): void; + enableVertexAttribArray(index: number): void; + finish(): void; + flush(): void; + framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; + frontFace(mode: number): void; + generateMipmap(target: number): void; + getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; + getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; + getAttachedShaders(program: WebGLProgram): WebGLShader[]; + getAttribLocation(program: WebGLProgram, name: string): number; + getBufferParameter(target: number, pname: number): any; + getContextAttributes(): WebGLContextAttributes; + getError(): number; + getExtension(name: string): any; + getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): any; + getParameter(pname: number): any; + getProgramInfoLog(program: WebGLProgram): string; + getProgramParameter(program: WebGLProgram, pname: number): any; + getRenderbufferParameter(target: number, pname: number): any; + getShaderInfoLog(shader: WebGLShader): string; + getShaderParameter(shader: WebGLShader, pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat; + getShaderSource(shader: WebGLShader): string; + getSupportedExtensions(): string[]; + getTexParameter(target: number, pname: number): any; + getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; + getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation; + getVertexAttrib(index: number, pname: number): any; + getVertexAttribOffset(index: number, pname: number): number; + hint(target: number, mode: number): void; + isBuffer(buffer: WebGLBuffer): boolean; + isContextLost(): boolean; + isEnabled(cap: number): boolean; + isFramebuffer(framebuffer: WebGLFramebuffer): boolean; + isProgram(program: WebGLProgram): boolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; + isShader(shader: WebGLShader): boolean; + isTexture(texture: WebGLTexture): boolean; + lineWidth(width: number): void; + linkProgram(program: WebGLProgram): void; + pixelStorei(pname: number, param: number): void; + polygonOffset(factor: number, units: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; + sampleCoverage(value: number, invert: boolean): void; + scissor(x: number, y: number, width: number, height: number): void; + shaderSource(shader: WebGLShader, source: string): void; + stencilFunc(func: number, ref: number, mask: number): void; + stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; + stencilMask(mask: number): void; + stencilMaskSeparate(face: number, mask: number): void; + stencilOp(fail: number, zfail: number, zpass: number): void; + stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; + texParameterf(target: number, pname: number, param: number): void; + texParameteri(target: number, pname: number, param: number): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; + uniform1f(location: WebGLUniformLocation, x: number): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform1i(location: WebGLUniformLocation, x: number): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform2f(location: WebGLUniformLocation, x: number, y: number): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform2i(location: WebGLUniformLocation, x: number, y: number): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + useProgram(program: WebGLProgram): void; + validateProgram(program: WebGLProgram): void; + vertexAttrib1f(indx: number, x: number): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; + vertexAttrib2f(indx: number, x: number, y: number): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; + vertexAttrib3f(indx: number, x: number, y: number, z: number): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; + vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; + vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; + viewport(x: number, y: number, width: number, height: number): void; + ACTIVE_ATTRIBUTES: number; + ACTIVE_TEXTURE: number; + ACTIVE_UNIFORMS: number; + ALIASED_LINE_WIDTH_RANGE: number; + ALIASED_POINT_SIZE_RANGE: number; + ALPHA: number; + ALPHA_BITS: number; + ALWAYS: number; + ARRAY_BUFFER: number; + ARRAY_BUFFER_BINDING: number; + ATTACHED_SHADERS: number; + BACK: number; + BLEND: number; + BLEND_COLOR: number; + BLEND_DST_ALPHA: number; + BLEND_DST_RGB: number; + BLEND_EQUATION: number; + BLEND_EQUATION_ALPHA: number; + BLEND_EQUATION_RGB: number; + BLEND_SRC_ALPHA: number; + BLEND_SRC_RGB: number; + BLUE_BITS: number; + BOOL: number; + BOOL_VEC2: number; + BOOL_VEC3: number; + BOOL_VEC4: number; + BROWSER_DEFAULT_WEBGL: number; + BUFFER_SIZE: number; + BUFFER_USAGE: number; + BYTE: number; + CCW: number; + CLAMP_TO_EDGE: number; + COLOR_ATTACHMENT0: number; + COLOR_BUFFER_BIT: number; + COLOR_CLEAR_VALUE: number; + COLOR_WRITEMASK: number; + COMPILE_STATUS: number; + COMPRESSED_TEXTURE_FORMATS: number; + CONSTANT_ALPHA: number; + CONSTANT_COLOR: number; + CONTEXT_LOST_WEBGL: number; + CULL_FACE: number; + CULL_FACE_MODE: number; + CURRENT_PROGRAM: number; + CURRENT_VERTEX_ATTRIB: number; + CW: number; + DECR: number; + DECR_WRAP: number; + DELETE_STATUS: number; + DEPTH_ATTACHMENT: number; + DEPTH_BITS: number; + DEPTH_BUFFER_BIT: number; + DEPTH_CLEAR_VALUE: number; + DEPTH_COMPONENT: number; + DEPTH_COMPONENT16: number; + DEPTH_FUNC: number; + DEPTH_RANGE: number; + DEPTH_STENCIL: number; + DEPTH_STENCIL_ATTACHMENT: number; + DEPTH_TEST: number; + DEPTH_WRITEMASK: number; + DITHER: number; + DONT_CARE: number; + DST_ALPHA: number; + DST_COLOR: number; + DYNAMIC_DRAW: number; + ELEMENT_ARRAY_BUFFER: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + EQUAL: number; + FASTEST: number; + FLOAT: number; + FLOAT_MAT2: number; + FLOAT_MAT3: number; + FLOAT_MAT4: number; + FLOAT_VEC2: number; + FLOAT_VEC3: number; + FLOAT_VEC4: number; + FRAGMENT_SHADER: number; + FRAMEBUFFER: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + FRAMEBUFFER_BINDING: number; + FRAMEBUFFER_COMPLETE: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + FRAMEBUFFER_UNSUPPORTED: number; + FRONT: number; + FRONT_AND_BACK: number; + FRONT_FACE: number; + FUNC_ADD: number; + FUNC_REVERSE_SUBTRACT: number; + FUNC_SUBTRACT: number; + GENERATE_MIPMAP_HINT: number; + GEQUAL: number; + GREATER: number; + GREEN_BITS: number; + HIGH_FLOAT: number; + HIGH_INT: number; + IMPLEMENTATION_COLOR_READ_FORMAT: number; + IMPLEMENTATION_COLOR_READ_TYPE: number; + INCR: number; + INCR_WRAP: number; + INT: number; + INT_VEC2: number; + INT_VEC3: number; + INT_VEC4: number; + INVALID_ENUM: number; + INVALID_FRAMEBUFFER_OPERATION: number; + INVALID_OPERATION: number; + INVALID_VALUE: number; + INVERT: number; + KEEP: number; + LEQUAL: number; + LESS: number; + LINEAR: number; + LINEAR_MIPMAP_LINEAR: number; + LINEAR_MIPMAP_NEAREST: number; + LINES: number; + LINE_LOOP: number; + LINE_STRIP: number; + LINE_WIDTH: number; + LINK_STATUS: number; + LOW_FLOAT: number; + LOW_INT: number; + LUMINANCE: number; + LUMINANCE_ALPHA: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + MAX_RENDERBUFFER_SIZE: number; + MAX_TEXTURE_IMAGE_UNITS: number; + MAX_TEXTURE_SIZE: number; + MAX_VARYING_VECTORS: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + MAX_VIEWPORT_DIMS: number; + MEDIUM_FLOAT: number; + MEDIUM_INT: number; + MIRRORED_REPEAT: number; + NEAREST: number; + NEAREST_MIPMAP_LINEAR: number; + NEAREST_MIPMAP_NEAREST: number; + NEVER: number; + NICEST: number; + NONE: number; + NOTEQUAL: number; + NO_ERROR: number; + ONE: number; + ONE_MINUS_CONSTANT_ALPHA: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_DST_ALPHA: number; + ONE_MINUS_DST_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + ONE_MINUS_SRC_COLOR: number; + OUT_OF_MEMORY: number; + PACK_ALIGNMENT: number; + POINTS: number; + POLYGON_OFFSET_FACTOR: number; + POLYGON_OFFSET_FILL: number; + POLYGON_OFFSET_UNITS: number; + RED_BITS: number; + RENDERBUFFER: number; + RENDERBUFFER_ALPHA_SIZE: number; + RENDERBUFFER_BINDING: number; + RENDERBUFFER_BLUE_SIZE: number; + RENDERBUFFER_DEPTH_SIZE: number; + RENDERBUFFER_GREEN_SIZE: number; + RENDERBUFFER_HEIGHT: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + RENDERBUFFER_RED_SIZE: number; + RENDERBUFFER_STENCIL_SIZE: number; + RENDERBUFFER_WIDTH: number; + RENDERER: number; + REPEAT: number; + REPLACE: number; + RGB: number; + RGB565: number; + RGB5_A1: number; + RGBA: number; + RGBA4: number; + SAMPLER_2D: number; + SAMPLER_CUBE: number; + SAMPLES: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + SAMPLE_BUFFERS: number; + SAMPLE_COVERAGE: number; + SAMPLE_COVERAGE_INVERT: number; + SAMPLE_COVERAGE_VALUE: number; + SCISSOR_BOX: number; + SCISSOR_TEST: number; + SHADER_TYPE: number; + SHADING_LANGUAGE_VERSION: number; + SHORT: number; + SRC_ALPHA: number; + SRC_ALPHA_SATURATE: number; + SRC_COLOR: number; + STATIC_DRAW: number; + STENCIL_ATTACHMENT: number; + STENCIL_BACK_FAIL: number; + STENCIL_BACK_FUNC: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + STENCIL_BACK_REF: number; + STENCIL_BACK_VALUE_MASK: number; + STENCIL_BACK_WRITEMASK: number; + STENCIL_BITS: number; + STENCIL_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + STENCIL_FAIL: number; + STENCIL_FUNC: number; + STENCIL_INDEX: number; + STENCIL_INDEX8: number; + STENCIL_PASS_DEPTH_FAIL: number; + STENCIL_PASS_DEPTH_PASS: number; + STENCIL_REF: number; + STENCIL_TEST: number; + STENCIL_VALUE_MASK: number; + STENCIL_WRITEMASK: number; + STREAM_DRAW: number; + SUBPIXEL_BITS: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE1: number; + TEXTURE10: number; + TEXTURE11: number; + TEXTURE12: number; + TEXTURE13: number; + TEXTURE14: number; + TEXTURE15: number; + TEXTURE16: number; + TEXTURE17: number; + TEXTURE18: number; + TEXTURE19: number; + TEXTURE2: number; + TEXTURE20: number; + TEXTURE21: number; + TEXTURE22: number; + TEXTURE23: number; + TEXTURE24: number; + TEXTURE25: number; + TEXTURE26: number; + TEXTURE27: number; + TEXTURE28: number; + TEXTURE29: number; + TEXTURE3: number; + TEXTURE30: number; + TEXTURE31: number; + TEXTURE4: number; + TEXTURE5: number; + TEXTURE6: number; + TEXTURE7: number; + TEXTURE8: number; + TEXTURE9: number; + TEXTURE_2D: number; + TEXTURE_BINDING_2D: number; + TEXTURE_BINDING_CUBE_MAP: number; + TEXTURE_CUBE_MAP: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + TEXTURE_MAG_FILTER: number; + TEXTURE_MIN_FILTER: number; + TEXTURE_WRAP_S: number; + TEXTURE_WRAP_T: number; + TRIANGLES: number; + TRIANGLE_FAN: number; + TRIANGLE_STRIP: number; + UNPACK_ALIGNMENT: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + UNPACK_FLIP_Y_WEBGL: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + UNSIGNED_BYTE: number; + UNSIGNED_INT: number; + UNSIGNED_SHORT: number; + UNSIGNED_SHORT_4_4_4_4: number; + UNSIGNED_SHORT_5_5_5_1: number; + UNSIGNED_SHORT_5_6_5: number; + VALIDATE_STATUS: number; + VENDOR: number; + VERSION: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + VERTEX_SHADER: number; + VIEWPORT: number; + ZERO: number; +} + +declare var WebGLRenderingContext: { + prototype: WebGLRenderingContext; + new(): WebGLRenderingContext; + ACTIVE_ATTRIBUTES: number; + ACTIVE_TEXTURE: number; + ACTIVE_UNIFORMS: number; + ALIASED_LINE_WIDTH_RANGE: number; + ALIASED_POINT_SIZE_RANGE: number; + ALPHA: number; + ALPHA_BITS: number; + ALWAYS: number; + ARRAY_BUFFER: number; + ARRAY_BUFFER_BINDING: number; + ATTACHED_SHADERS: number; + BACK: number; + BLEND: number; + BLEND_COLOR: number; + BLEND_DST_ALPHA: number; + BLEND_DST_RGB: number; + BLEND_EQUATION: number; + BLEND_EQUATION_ALPHA: number; + BLEND_EQUATION_RGB: number; + BLEND_SRC_ALPHA: number; + BLEND_SRC_RGB: number; + BLUE_BITS: number; + BOOL: number; + BOOL_VEC2: number; + BOOL_VEC3: number; + BOOL_VEC4: number; + BROWSER_DEFAULT_WEBGL: number; + BUFFER_SIZE: number; + BUFFER_USAGE: number; + BYTE: number; + CCW: number; + CLAMP_TO_EDGE: number; + COLOR_ATTACHMENT0: number; + COLOR_BUFFER_BIT: number; + COLOR_CLEAR_VALUE: number; + COLOR_WRITEMASK: number; + COMPILE_STATUS: number; + COMPRESSED_TEXTURE_FORMATS: number; + CONSTANT_ALPHA: number; + CONSTANT_COLOR: number; + CONTEXT_LOST_WEBGL: number; + CULL_FACE: number; + CULL_FACE_MODE: number; + CURRENT_PROGRAM: number; + CURRENT_VERTEX_ATTRIB: number; + CW: number; + DECR: number; + DECR_WRAP: number; + DELETE_STATUS: number; + DEPTH_ATTACHMENT: number; + DEPTH_BITS: number; + DEPTH_BUFFER_BIT: number; + DEPTH_CLEAR_VALUE: number; + DEPTH_COMPONENT: number; + DEPTH_COMPONENT16: number; + DEPTH_FUNC: number; + DEPTH_RANGE: number; + DEPTH_STENCIL: number; + DEPTH_STENCIL_ATTACHMENT: number; + DEPTH_TEST: number; + DEPTH_WRITEMASK: number; + DITHER: number; + DONT_CARE: number; + DST_ALPHA: number; + DST_COLOR: number; + DYNAMIC_DRAW: number; + ELEMENT_ARRAY_BUFFER: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + EQUAL: number; + FASTEST: number; + FLOAT: number; + FLOAT_MAT2: number; + FLOAT_MAT3: number; + FLOAT_MAT4: number; + FLOAT_VEC2: number; + FLOAT_VEC3: number; + FLOAT_VEC4: number; + FRAGMENT_SHADER: number; + FRAMEBUFFER: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + FRAMEBUFFER_BINDING: number; + FRAMEBUFFER_COMPLETE: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + FRAMEBUFFER_UNSUPPORTED: number; + FRONT: number; + FRONT_AND_BACK: number; + FRONT_FACE: number; + FUNC_ADD: number; + FUNC_REVERSE_SUBTRACT: number; + FUNC_SUBTRACT: number; + GENERATE_MIPMAP_HINT: number; + GEQUAL: number; + GREATER: number; + GREEN_BITS: number; + HIGH_FLOAT: number; + HIGH_INT: number; + IMPLEMENTATION_COLOR_READ_FORMAT: number; + IMPLEMENTATION_COLOR_READ_TYPE: number; + INCR: number; + INCR_WRAP: number; + INT: number; + INT_VEC2: number; + INT_VEC3: number; + INT_VEC4: number; + INVALID_ENUM: number; + INVALID_FRAMEBUFFER_OPERATION: number; + INVALID_OPERATION: number; + INVALID_VALUE: number; + INVERT: number; + KEEP: number; + LEQUAL: number; + LESS: number; + LINEAR: number; + LINEAR_MIPMAP_LINEAR: number; + LINEAR_MIPMAP_NEAREST: number; + LINES: number; + LINE_LOOP: number; + LINE_STRIP: number; + LINE_WIDTH: number; + LINK_STATUS: number; + LOW_FLOAT: number; + LOW_INT: number; + LUMINANCE: number; + LUMINANCE_ALPHA: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + MAX_RENDERBUFFER_SIZE: number; + MAX_TEXTURE_IMAGE_UNITS: number; + MAX_TEXTURE_SIZE: number; + MAX_VARYING_VECTORS: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + MAX_VIEWPORT_DIMS: number; + MEDIUM_FLOAT: number; + MEDIUM_INT: number; + MIRRORED_REPEAT: number; + NEAREST: number; + NEAREST_MIPMAP_LINEAR: number; + NEAREST_MIPMAP_NEAREST: number; + NEVER: number; + NICEST: number; + NONE: number; + NOTEQUAL: number; + NO_ERROR: number; + ONE: number; + ONE_MINUS_CONSTANT_ALPHA: number; + ONE_MINUS_CONSTANT_COLOR: number; + ONE_MINUS_DST_ALPHA: number; + ONE_MINUS_DST_COLOR: number; + ONE_MINUS_SRC_ALPHA: number; + ONE_MINUS_SRC_COLOR: number; + OUT_OF_MEMORY: number; + PACK_ALIGNMENT: number; + POINTS: number; + POLYGON_OFFSET_FACTOR: number; + POLYGON_OFFSET_FILL: number; + POLYGON_OFFSET_UNITS: number; + RED_BITS: number; + RENDERBUFFER: number; + RENDERBUFFER_ALPHA_SIZE: number; + RENDERBUFFER_BINDING: number; + RENDERBUFFER_BLUE_SIZE: number; + RENDERBUFFER_DEPTH_SIZE: number; + RENDERBUFFER_GREEN_SIZE: number; + RENDERBUFFER_HEIGHT: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + RENDERBUFFER_RED_SIZE: number; + RENDERBUFFER_STENCIL_SIZE: number; + RENDERBUFFER_WIDTH: number; + RENDERER: number; + REPEAT: number; + REPLACE: number; + RGB: number; + RGB565: number; + RGB5_A1: number; + RGBA: number; + RGBA4: number; + SAMPLER_2D: number; + SAMPLER_CUBE: number; + SAMPLES: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + SAMPLE_BUFFERS: number; + SAMPLE_COVERAGE: number; + SAMPLE_COVERAGE_INVERT: number; + SAMPLE_COVERAGE_VALUE: number; + SCISSOR_BOX: number; + SCISSOR_TEST: number; + SHADER_TYPE: number; + SHADING_LANGUAGE_VERSION: number; + SHORT: number; + SRC_ALPHA: number; + SRC_ALPHA_SATURATE: number; + SRC_COLOR: number; + STATIC_DRAW: number; + STENCIL_ATTACHMENT: number; + STENCIL_BACK_FAIL: number; + STENCIL_BACK_FUNC: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + STENCIL_BACK_REF: number; + STENCIL_BACK_VALUE_MASK: number; + STENCIL_BACK_WRITEMASK: number; + STENCIL_BITS: number; + STENCIL_BUFFER_BIT: number; + STENCIL_CLEAR_VALUE: number; + STENCIL_FAIL: number; + STENCIL_FUNC: number; + STENCIL_INDEX: number; + STENCIL_INDEX8: number; + STENCIL_PASS_DEPTH_FAIL: number; + STENCIL_PASS_DEPTH_PASS: number; + STENCIL_REF: number; + STENCIL_TEST: number; + STENCIL_VALUE_MASK: number; + STENCIL_WRITEMASK: number; + STREAM_DRAW: number; + SUBPIXEL_BITS: number; + TEXTURE: number; + TEXTURE0: number; + TEXTURE1: number; + TEXTURE10: number; + TEXTURE11: number; + TEXTURE12: number; + TEXTURE13: number; + TEXTURE14: number; + TEXTURE15: number; + TEXTURE16: number; + TEXTURE17: number; + TEXTURE18: number; + TEXTURE19: number; + TEXTURE2: number; + TEXTURE20: number; + TEXTURE21: number; + TEXTURE22: number; + TEXTURE23: number; + TEXTURE24: number; + TEXTURE25: number; + TEXTURE26: number; + TEXTURE27: number; + TEXTURE28: number; + TEXTURE29: number; + TEXTURE3: number; + TEXTURE30: number; + TEXTURE31: number; + TEXTURE4: number; + TEXTURE5: number; + TEXTURE6: number; + TEXTURE7: number; + TEXTURE8: number; + TEXTURE9: number; + TEXTURE_2D: number; + TEXTURE_BINDING_2D: number; + TEXTURE_BINDING_CUBE_MAP: number; + TEXTURE_CUBE_MAP: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + TEXTURE_MAG_FILTER: number; + TEXTURE_MIN_FILTER: number; + TEXTURE_WRAP_S: number; + TEXTURE_WRAP_T: number; + TRIANGLES: number; + TRIANGLE_FAN: number; + TRIANGLE_STRIP: number; + UNPACK_ALIGNMENT: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + UNPACK_FLIP_Y_WEBGL: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + UNSIGNED_BYTE: number; + UNSIGNED_INT: number; + UNSIGNED_SHORT: number; + UNSIGNED_SHORT_4_4_4_4: number; + UNSIGNED_SHORT_5_5_5_1: number; + UNSIGNED_SHORT_5_6_5: number; + VALIDATE_STATUS: number; + VENDOR: number; + VERSION: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + VERTEX_ATTRIB_ARRAY_ENABLED: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + VERTEX_SHADER: number; + VIEWPORT: number; + ZERO: number; +} + +interface WebGLShader extends WebGLObject { +} + +declare var WebGLShader: { + prototype: WebGLShader; + new(): WebGLShader; +} + +interface WebGLShaderPrecisionFormat { + precision: number; + rangeMax: number; + rangeMin: number; +} + +declare var WebGLShaderPrecisionFormat: { + prototype: WebGLShaderPrecisionFormat; + new(): WebGLShaderPrecisionFormat; +} + +interface WebGLTexture extends WebGLObject { +} + +declare var WebGLTexture: { + prototype: WebGLTexture; + new(): WebGLTexture; +} + +interface WebGLUniformLocation { +} + +declare var WebGLUniformLocation: { + prototype: WebGLUniformLocation; + new(): WebGLUniformLocation; +} + +interface WebKitCSSMatrix { + a: number; + b: number; + c: number; + d: number; + e: number; + f: number; + m11: number; + m12: number; + m13: number; + m14: number; + m21: number; + m22: number; + m23: number; + m24: number; + m31: number; + m32: number; + m33: number; + m34: number; + m41: number; + m42: number; + m43: number; + m44: number; + inverse(): WebKitCSSMatrix; + multiply(secondMatrix: WebKitCSSMatrix): WebKitCSSMatrix; + rotate(angleX: number, angleY?: number, angleZ?: number): WebKitCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): WebKitCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): WebKitCSSMatrix; + setMatrixValue(value: string): void; + skewX(angle: number): WebKitCSSMatrix; + skewY(angle: number): WebKitCSSMatrix; + toString(): string; + translate(x: number, y: number, z?: number): WebKitCSSMatrix; +} + +declare var WebKitCSSMatrix: { + prototype: WebKitCSSMatrix; + new(text?: string): WebKitCSSMatrix; +} + +interface WebKitPoint { + x: number; + y: number; +} + +declare var WebKitPoint: { + prototype: WebKitPoint; + new(x?: number, y?: number): WebKitPoint; +} + +interface WebSocket extends EventTarget { + binaryType: string; + bufferedAmount: number; + extensions: string; + onclose: (ev: CloseEvent) => any; + onerror: (ev: Event) => any; + onmessage: (ev: MessageEvent) => any; + onopen: (ev: Event) => any; + protocol: string; + readyState: number; + url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + CLOSED: number; + CLOSING: number; + CONNECTING: number; + OPEN: number; + addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var WebSocket: { + prototype: WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; + CLOSED: number; + CLOSING: number; + CONNECTING: number; + OPEN: number; +} + +interface WheelEvent extends MouseEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + getCurrentPoint(element: Element): void; + initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; + DOM_DELTA_PIXEL: number; +} + +declare var WheelEvent: { + prototype: WheelEvent; + new(typeArg: string, eventInitDict?: WheelEventInit): WheelEvent; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; + DOM_DELTA_PIXEL: number; +} + +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64 { + animationStartTime: number; + applicationCache: ApplicationCache; + clientInformation: Navigator; + closed: boolean; + crypto: Crypto; + defaultStatus: string; + devicePixelRatio: number; + doNotTrack: string; + document: Document; + event: Event; + external: External; + frameElement: Element; + frames: Window; + history: History; + innerHeight: number; + innerWidth: number; + length: number; + location: Location; + locationbar: BarProp; + menubar: BarProp; + msAnimationStartTime: number; + name: string; + navigator: Navigator; + offscreenBuffering: string | boolean; + onabort: (ev: Event) => any; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onblur: (ev: FocusEvent) => any; + oncanplay: (ev: Event) => any; + oncanplaythrough: (ev: Event) => any; + onchange: (ev: Event) => any; + onclick: (ev: MouseEvent) => any; + oncompassneedscalibration: (ev: Event) => any; + oncontextmenu: (ev: PointerEvent) => any; + ondblclick: (ev: MouseEvent) => any; + ondevicemotion: (ev: DeviceMotionEvent) => any; + ondeviceorientation: (ev: DeviceOrientationEvent) => any; + ondrag: (ev: DragEvent) => any; + ondragend: (ev: DragEvent) => any; + ondragenter: (ev: DragEvent) => any; + ondragleave: (ev: DragEvent) => any; + ondragover: (ev: DragEvent) => any; + ondragstart: (ev: DragEvent) => any; + ondrop: (ev: DragEvent) => any; + ondurationchange: (ev: Event) => any; + onemptied: (ev: Event) => any; + onended: (ev: Event) => any; + onerror: ErrorEventHandler; + onfocus: (ev: FocusEvent) => any; + onhashchange: (ev: HashChangeEvent) => any; + oninput: (ev: Event) => any; + onkeydown: (ev: KeyboardEvent) => any; + onkeypress: (ev: KeyboardEvent) => any; + onkeyup: (ev: KeyboardEvent) => any; + onload: (ev: Event) => any; + onloadeddata: (ev: Event) => any; + onloadedmetadata: (ev: Event) => any; + onloadstart: (ev: Event) => any; + onmessage: (ev: MessageEvent) => any; + onmousedown: (ev: MouseEvent) => any; + onmouseenter: (ev: MouseEvent) => any; + onmouseleave: (ev: MouseEvent) => any; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onmouseover: (ev: MouseEvent) => any; + onmouseup: (ev: MouseEvent) => any; + onmousewheel: (ev: MouseWheelEvent) => any; + onmsgesturechange: (ev: MSGestureEvent) => any; + onmsgesturedoubletap: (ev: MSGestureEvent) => any; + onmsgestureend: (ev: MSGestureEvent) => any; + onmsgesturehold: (ev: MSGestureEvent) => any; + onmsgesturestart: (ev: MSGestureEvent) => any; + onmsgesturetap: (ev: MSGestureEvent) => any; + onmsinertiastart: (ev: MSGestureEvent) => any; + onmspointercancel: (ev: MSPointerEvent) => any; + onmspointerdown: (ev: MSPointerEvent) => any; + onmspointerenter: (ev: MSPointerEvent) => any; + onmspointerleave: (ev: MSPointerEvent) => any; + onmspointermove: (ev: MSPointerEvent) => any; + onmspointerout: (ev: MSPointerEvent) => any; + onmspointerover: (ev: MSPointerEvent) => any; + onmspointerup: (ev: MSPointerEvent) => any; + onoffline: (ev: Event) => any; + ononline: (ev: Event) => any; + onorientationchange: (ev: Event) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onpageshow: (ev: PageTransitionEvent) => any; + onpause: (ev: Event) => any; + onplay: (ev: Event) => any; + onplaying: (ev: Event) => any; + onpopstate: (ev: PopStateEvent) => any; + onprogress: (ev: ProgressEvent) => any; + onratechange: (ev: Event) => any; + onreadystatechange: (ev: ProgressEvent) => any; + onreset: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + onscroll: (ev: UIEvent) => any; + onseeked: (ev: Event) => any; + onseeking: (ev: Event) => any; + onselect: (ev: UIEvent) => any; + onstalled: (ev: Event) => any; + onstorage: (ev: StorageEvent) => any; + onsubmit: (ev: Event) => any; + onsuspend: (ev: Event) => any; + ontimeupdate: (ev: Event) => any; + ontouchcancel: any; + ontouchend: any; + ontouchmove: any; + ontouchstart: any; + onunload: (ev: Event) => any; + onvolumechange: (ev: Event) => any; + onwaiting: (ev: Event) => any; + opener: Window; + orientation: string | number; + outerHeight: number; + outerWidth: number; + pageXOffset: number; + pageYOffset: number; + parent: Window; + performance: Performance; + personalbar: BarProp; + screen: Screen; + screenLeft: number; + screenTop: number; + screenX: number; + screenY: number; + scrollX: number; + scrollY: number; + scrollbars: BarProp; + self: Window; + status: string; + statusbar: BarProp; + styleMedia: StyleMedia; + toolbar: BarProp; + top: Window; + window: Window; + URL: URL; + alert(message?: any): void; + blur(): void; + cancelAnimationFrame(handle: number): void; + captureEvents(): void; + close(): void; + confirm(message?: string): boolean; + focus(): void; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; + getSelection(): Selection; + matchMedia(mediaQuery: string): MediaQueryList; + moveBy(x?: number, y?: number): void; + moveTo(x?: number, y?: number): void; + msCancelRequestAnimationFrame(handle: number): void; + msMatchMedia(mediaQuery: string): MediaQueryList; + msRequestAnimationFrame(callback: FrameRequestCallback): number; + msWriteProfilerMark(profilerMarkName: string): void; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + postMessage(message: any, targetOrigin: string, ports?: any): void; + print(): void; + prompt(message?: string, _default?: string): string; + releaseEvents(): void; + requestAnimationFrame(callback: FrameRequestCallback): number; + resizeBy(x?: number, y?: number): void; + resizeTo(x?: number, y?: number): void; + scroll(x?: number, y?: number): void; + scrollBy(x?: number, y?: number): void; + scrollTo(x?: number, y?: number): void; + webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; + webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; + 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; + addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; + addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "compassneedscalibration", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; + addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; + addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; + addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; + addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: Window; +} + +declare var Window: { + prototype: Window; + new(): Window; +} + +interface Worker extends EventTarget, AbstractWorker { + onmessage: (ev: MessageEvent) => any; + postMessage(message: any, ports?: any): void; + terminate(): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Worker: { + prototype: Worker; + new(stringUrl: string): Worker; +} + +interface XMLDocument extends Document { +} + +declare var XMLDocument: { + prototype: XMLDocument; + new(): XMLDocument; +} + +interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { + msCaching: string; + onreadystatechange: (ev: ProgressEvent) => any; + readyState: number; + response: any; + responseBody: any; + responseText: string; + responseType: string; + responseXML: any; + status: number; + statusText: string; + timeout: number; + upload: XMLHttpRequestUpload; + withCredentials: boolean; + abort(): void; + getAllResponseHeaders(): string; + getResponseHeader(header: string): string; + msCachingEnabled(): boolean; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + overrideMimeType(mime: string): void; + send(data?: Document): void; + send(data?: string): void; + send(data?: any): void; + setRequestHeader(header: string, value: string): void; + DONE: number; + HEADERS_RECEIVED: number; + LOADING: number; + OPENED: number; + UNSENT: number; + 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; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new(): XMLHttpRequest; + DONE: number; + HEADERS_RECEIVED: number; + LOADING: number; + OPENED: number; + UNSENT: number; + create(): XMLHttpRequest; +} + +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequestUpload: { + prototype: XMLHttpRequestUpload; + new(): XMLHttpRequestUpload; +} + +interface XMLSerializer { + serializeToString(target: Node): string; +} + +declare var XMLSerializer: { + prototype: XMLSerializer; + new(): XMLSerializer; +} + +interface XPathEvaluator { + createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; + createNSResolver(nodeResolver?: Node): XPathNSResolver; + evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver, type: number, result: XPathResult): XPathResult; +} + +declare var XPathEvaluator: { + prototype: XPathEvaluator; + new(): XPathEvaluator; +} + +interface XPathExpression { + evaluate(contextNode: Node, type: number, result: XPathResult): XPathExpression; +} + +declare var XPathExpression: { + prototype: XPathExpression; + new(): XPathExpression; +} + +interface XPathNSResolver { + lookupNamespaceURI(prefix: string): string; +} + +declare var XPathNSResolver: { + prototype: XPathNSResolver; + new(): XPathNSResolver; +} + +interface XPathResult { + booleanValue: boolean; + invalidIteratorState: boolean; + numberValue: number; + resultType: number; + singleNodeValue: Node; + snapshotLength: number; + stringValue: string; + iterateNext(): Node; + snapshotItem(index: number): Node; + ANY_TYPE: number; + ANY_UNORDERED_NODE_TYPE: number; + BOOLEAN_TYPE: number; + FIRST_ORDERED_NODE_TYPE: number; + NUMBER_TYPE: number; + ORDERED_NODE_ITERATOR_TYPE: number; + ORDERED_NODE_SNAPSHOT_TYPE: number; + STRING_TYPE: number; + UNORDERED_NODE_ITERATOR_TYPE: number; + UNORDERED_NODE_SNAPSHOT_TYPE: number; +} + +declare var XPathResult: { + prototype: XPathResult; + new(): XPathResult; + ANY_TYPE: number; + ANY_UNORDERED_NODE_TYPE: number; + BOOLEAN_TYPE: number; + FIRST_ORDERED_NODE_TYPE: number; + NUMBER_TYPE: number; + ORDERED_NODE_ITERATOR_TYPE: number; + ORDERED_NODE_SNAPSHOT_TYPE: number; + STRING_TYPE: number; + UNORDERED_NODE_ITERATOR_TYPE: number; + UNORDERED_NODE_SNAPSHOT_TYPE: number; +} + +interface XSLTProcessor { + clearParameters(): void; + getParameter(namespaceURI: string, localName: string): any; + importStylesheet(style: Node): void; + removeParameter(namespaceURI: string, localName: string): void; + reset(): void; + setParameter(namespaceURI: string, localName: string, value: any): void; + transformToDocument(source: Node): Document; + transformToFragment(source: Node, document: Document): DocumentFragment; +} + +declare var XSLTProcessor: { + prototype: XSLTProcessor; + new(): XSLTProcessor; +} + +interface AbstractWorker { + onerror: (ev: Event) => any; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface ChildNode { + remove(): void; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface DocumentEvent { + createEvent(eventInterface:"AnimationEvent"): AnimationEvent; + createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent; + createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; + createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; + createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; + createEvent(eventInterface:"CloseEvent"): CloseEvent; + createEvent(eventInterface:"CommandEvent"): CommandEvent; + createEvent(eventInterface:"CompositionEvent"): CompositionEvent; + createEvent(eventInterface:"CustomEvent"): CustomEvent; + createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent; + createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent; + createEvent(eventInterface:"DragEvent"): DragEvent; + createEvent(eventInterface:"ErrorEvent"): ErrorEvent; + createEvent(eventInterface:"Event"): Event; + createEvent(eventInterface:"Events"): Event; + createEvent(eventInterface:"FocusEvent"): FocusEvent; + createEvent(eventInterface:"GamepadEvent"): GamepadEvent; + createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; + createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; + createEvent(eventInterface:"KeyboardEvent"): KeyboardEvent; + createEvent(eventInterface:"LongRunningScriptDetectedEvent"): LongRunningScriptDetectedEvent; + createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent; + createEvent(eventInterface:"MSManipulationEvent"): MSManipulationEvent; + createEvent(eventInterface:"MSMediaKeyMessageEvent"): MSMediaKeyMessageEvent; + createEvent(eventInterface:"MSMediaKeyNeededEvent"): MSMediaKeyNeededEvent; + createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent; + createEvent(eventInterface:"MSSiteModeEvent"): MSSiteModeEvent; + createEvent(eventInterface:"MessageEvent"): MessageEvent; + createEvent(eventInterface:"MouseEvent"): MouseEvent; + createEvent(eventInterface:"MouseEvents"): MouseEvent; + createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent; + createEvent(eventInterface:"MutationEvent"): MutationEvent; + createEvent(eventInterface:"MutationEvents"): MutationEvent; + createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent; + createEvent(eventInterface:"NavigationEvent"): NavigationEvent; + createEvent(eventInterface:"NavigationEventWithReferrer"): NavigationEventWithReferrer; + createEvent(eventInterface:"OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; + createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; + createEvent(eventInterface:"PointerEvent"): PointerEvent; + createEvent(eventInterface:"PopStateEvent"): PopStateEvent; + createEvent(eventInterface:"ProgressEvent"): ProgressEvent; + createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; + createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; + createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"StorageEvent"): StorageEvent; + createEvent(eventInterface:"TextEvent"): TextEvent; + createEvent(eventInterface:"TouchEvent"): TouchEvent; + createEvent(eventInterface:"TrackEvent"): TrackEvent; + createEvent(eventInterface:"TransitionEvent"): TransitionEvent; + createEvent(eventInterface:"UIEvent"): UIEvent; + createEvent(eventInterface:"UIEvents"): UIEvent; + createEvent(eventInterface:"UnviewableContentIdentifiedEvent"): UnviewableContentIdentifiedEvent; + createEvent(eventInterface:"WebGLContextEvent"): WebGLContextEvent; + createEvent(eventInterface:"WheelEvent"): WheelEvent; + createEvent(eventInterface: string): Event; +} + +interface ElementTraversal { + childElementCount: number; + firstElementChild: Element; + lastElementChild: Element; + nextElementSibling: Element; + previousElementSibling: Element; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface GlobalEventHandlers { + onpointercancel: (ev: PointerEvent) => any; + onpointerdown: (ev: PointerEvent) => any; + onpointerenter: (ev: PointerEvent) => any; + onpointerleave: (ev: PointerEvent) => any; + onpointermove: (ev: PointerEvent) => any; + onpointerout: (ev: PointerEvent) => any; + onpointerover: (ev: PointerEvent) => any; + onpointerup: (ev: PointerEvent) => any; + onwheel: (ev: WheelEvent) => any; + addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; + addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface HTMLTableAlignment { + /** + * Sets or retrieves a value that you can use to implement your own ch functionality for the object. + */ + ch: string; + /** + * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. + */ + chOff: string; + /** + * Sets or retrieves how text and other content are vertically aligned within the object that contains them. + */ + vAlign: string; +} + +interface IDBEnvironment { + indexedDB: IDBFactory; + msIndexedDB: IDBFactory; +} + +interface LinkStyle { + sheet: StyleSheet; +} + +interface MSBaseReader { + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + onloadend: (ev: ProgressEvent) => any; + onloadstart: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + readyState: number; + result: any; + abort(): void; + DONE: number; + EMPTY: number; + LOADING: number; + 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; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface MSFileSaver { + msSaveBlob(blob: any, defaultName?: string): boolean; + msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; +} + +interface MSNavigatorDoNotTrack { + confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; + confirmWebWideTrackingException(args: ExceptionInformation): boolean; + removeSiteSpecificTrackingException(args: ExceptionInformation): void; + removeWebWideTrackingException(args: ExceptionInformation): void; + storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; + storeWebWideTrackingException(args: StoreExceptionsInformation): void; +} + +interface NavigatorContentUtils { +} + +interface NavigatorGeolocation { + geolocation: Geolocation; +} + +interface NavigatorID { + appName: string; + appVersion: string; + platform: string; + product: string; + productSub: string; + userAgent: string; + vendor: string; + vendorSub: string; +} + +interface NavigatorOnLine { + onLine: boolean; +} + +interface NavigatorStorageUtils { +} + +interface NodeSelector { + querySelector(selectors: string): Element; + querySelectorAll(selectors: string): NodeListOf; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface SVGAnimatedPathData { + pathSegList: SVGPathSegList; +} + +interface SVGAnimatedPoints { + animatedPoints: SVGPointList; + points: SVGPointList; +} + +interface SVGExternalResourcesRequired { + externalResourcesRequired: SVGAnimatedBoolean; +} + +interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { + height: SVGAnimatedLength; + result: SVGAnimatedString; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + y: SVGAnimatedLength; +} + +interface SVGFitToViewBox { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + viewBox: SVGAnimatedRect; +} + +interface SVGLangSpace { + xmllang: string; + xmlspace: string; +} + +interface SVGLocatable { + farthestViewportElement: SVGElement; + nearestViewportElement: SVGElement; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; +} + +interface SVGStylable { + className: any; + style: CSSStyleDeclaration; +} + +interface SVGTests { + requiredExtensions: SVGStringList; + requiredFeatures: SVGStringList; + systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface SVGTransformable extends SVGLocatable { + transform: SVGAnimatedTransformList; +} + +interface SVGURIReference { + href: SVGAnimatedString; +} + +interface WindowBase64 { + atob(encodedString: string): string; + btoa(rawString: string): string; +} + +interface WindowConsole { + console: Console; +} + +interface WindowLocalStorage { + localStorage: Storage; +} + +interface WindowSessionStorage { + sessionStorage: Storage; +} + +interface WindowTimers extends Object, WindowTimersExtension { + clearInterval(handle: number): void; + clearTimeout(handle: number): void; + setInterval(handler: any, timeout?: any, ...args: any[]): number; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; +} + +interface WindowTimersExtension { + clearImmediate(handle: number): void; + msClearImmediate(handle: number): void; + msSetImmediate(expression: any, ...args: any[]): number; + setImmediate(expression: any, ...args: any[]): number; +} + +interface XMLHttpRequestEventTarget { + onabort: (ev: Event) => any; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + onloadend: (ev: ProgressEvent) => any; + onloadstart: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + ontimeout: (ev: ProgressEvent) => any; + 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; + addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "timeout", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface StorageEventInit extends EventInit { + key?: string; + oldValue?: string; + newValue?: string; + url: string; + storageArea?: Storage; +} + +interface IDBObjectStoreParameters { + keyPath?: string | string[]; + autoIncrement?: boolean; +} + +interface IDBIndexParameters { + unique?: boolean; + multiEntry?: boolean; +} + +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; +} + +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 HTMLTemplateElement extends HTMLElement { + content: DocumentFragment; +} + +declare var HTMLTemplateElement: { + prototype: HTMLTemplateElement; + new(): HTMLTemplateElement; +} + +interface HTMLPictureElement extends HTMLElement { +} + +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; +} + +declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; + +interface ErrorEventHandler { + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; +} +interface PositionCallback { + (position: Position): void; +} +interface PositionErrorCallback { + (error: PositionError): void; +} +interface MediaQueryListListener { + (mql: MediaQueryList): void; +} +interface MSLaunchUriCallback { + (): void; +} +interface FrameRequestCallback { + (time: number): void; +} +interface MSUnsafeFunctionCallback { + (): any; +} +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; +} +interface MutationCallback { + (mutations: MutationRecord[], observer: MutationObserver): void; +} +interface DecodeSuccessCallback { + (decodedData: AudioBuffer): void; +} +interface DecodeErrorCallback { + (error: DOMException): void; +} +interface FunctionStringCallback { + (data: string): void; +} +declare var Audio: {new(src?: string): HTMLAudioElement; }; +declare var Image: {new(width?: number, height?: number): HTMLImageElement; }; +declare var Option: {new(text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; +declare var animationStartTime: number; +declare var applicationCache: ApplicationCache; +declare var clientInformation: Navigator; +declare var closed: boolean; +declare var crypto: Crypto; +declare var defaultStatus: string; +declare var devicePixelRatio: number; +declare var doNotTrack: string; +declare var document: Document; +declare var event: Event; +declare var external: External; +declare var frameElement: Element; +declare var frames: Window; +declare var history: History; +declare var innerHeight: number; +declare var innerWidth: number; +declare var length: number; +declare var location: Location; +declare var locationbar: BarProp; +declare var menubar: BarProp; +declare var msAnimationStartTime: number; +declare var name: string; +declare var navigator: Navigator; +declare var offscreenBuffering: string | boolean; +declare var onabort: (ev: Event) => any; +declare var onafterprint: (ev: Event) => any; +declare var onbeforeprint: (ev: Event) => any; +declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; +declare var onblur: (ev: FocusEvent) => any; +declare var oncanplay: (ev: Event) => any; +declare var oncanplaythrough: (ev: Event) => any; +declare var onchange: (ev: Event) => any; +declare var onclick: (ev: MouseEvent) => any; +declare var oncompassneedscalibration: (ev: Event) => any; +declare var oncontextmenu: (ev: PointerEvent) => any; +declare var ondblclick: (ev: MouseEvent) => any; +declare var ondevicemotion: (ev: DeviceMotionEvent) => any; +declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; +declare var ondrag: (ev: DragEvent) => any; +declare var ondragend: (ev: DragEvent) => any; +declare var ondragenter: (ev: DragEvent) => any; +declare var ondragleave: (ev: DragEvent) => any; +declare var ondragover: (ev: DragEvent) => any; +declare var ondragstart: (ev: DragEvent) => any; +declare var ondrop: (ev: DragEvent) => any; +declare var ondurationchange: (ev: Event) => any; +declare var onemptied: (ev: Event) => any; +declare var onended: (ev: Event) => any; +declare var onerror: ErrorEventHandler; +declare var onfocus: (ev: FocusEvent) => any; +declare var onhashchange: (ev: HashChangeEvent) => any; +declare var oninput: (ev: Event) => any; +declare var onkeydown: (ev: KeyboardEvent) => any; +declare var onkeypress: (ev: KeyboardEvent) => any; +declare var onkeyup: (ev: KeyboardEvent) => any; +declare var onload: (ev: Event) => any; +declare var onloadeddata: (ev: Event) => any; +declare var onloadedmetadata: (ev: Event) => any; +declare var onloadstart: (ev: Event) => any; +declare var onmessage: (ev: MessageEvent) => any; +declare var onmousedown: (ev: MouseEvent) => any; +declare var onmouseenter: (ev: MouseEvent) => any; +declare var onmouseleave: (ev: MouseEvent) => any; +declare var onmousemove: (ev: MouseEvent) => any; +declare var onmouseout: (ev: MouseEvent) => any; +declare var onmouseover: (ev: MouseEvent) => any; +declare var onmouseup: (ev: MouseEvent) => any; +declare var onmousewheel: (ev: MouseWheelEvent) => any; +declare var onmsgesturechange: (ev: MSGestureEvent) => any; +declare var onmsgesturedoubletap: (ev: MSGestureEvent) => any; +declare var onmsgestureend: (ev: MSGestureEvent) => any; +declare var onmsgesturehold: (ev: MSGestureEvent) => any; +declare var onmsgesturestart: (ev: MSGestureEvent) => any; +declare var onmsgesturetap: (ev: MSGestureEvent) => any; +declare var onmsinertiastart: (ev: MSGestureEvent) => any; +declare var onmspointercancel: (ev: MSPointerEvent) => any; +declare var onmspointerdown: (ev: MSPointerEvent) => any; +declare var onmspointerenter: (ev: MSPointerEvent) => any; +declare var onmspointerleave: (ev: MSPointerEvent) => any; +declare var onmspointermove: (ev: MSPointerEvent) => any; +declare var onmspointerout: (ev: MSPointerEvent) => any; +declare var onmspointerover: (ev: MSPointerEvent) => any; +declare var onmspointerup: (ev: MSPointerEvent) => any; +declare var onoffline: (ev: Event) => any; +declare var ononline: (ev: Event) => any; +declare var onorientationchange: (ev: Event) => any; +declare var onpagehide: (ev: PageTransitionEvent) => any; +declare var onpageshow: (ev: PageTransitionEvent) => any; +declare var onpause: (ev: Event) => any; +declare var onplay: (ev: Event) => any; +declare var onplaying: (ev: Event) => any; +declare var onpopstate: (ev: PopStateEvent) => any; +declare var onprogress: (ev: ProgressEvent) => any; +declare var onratechange: (ev: Event) => any; +declare var onreadystatechange: (ev: ProgressEvent) => any; +declare var onreset: (ev: Event) => any; +declare var onresize: (ev: UIEvent) => any; +declare var onscroll: (ev: UIEvent) => any; +declare var onseeked: (ev: Event) => any; +declare var onseeking: (ev: Event) => any; +declare var onselect: (ev: UIEvent) => any; +declare var onstalled: (ev: Event) => any; +declare var onstorage: (ev: StorageEvent) => any; +declare var onsubmit: (ev: Event) => any; +declare var onsuspend: (ev: Event) => any; +declare var ontimeupdate: (ev: Event) => any; +declare var ontouchcancel: any; +declare var ontouchend: any; +declare var ontouchmove: any; +declare var ontouchstart: any; +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 | number; +declare var outerHeight: number; +declare var outerWidth: number; +declare var pageXOffset: number; +declare var pageYOffset: number; +declare var parent: Window; +declare var performance: Performance; +declare var personalbar: BarProp; +declare var screen: Screen; +declare var screenLeft: number; +declare var screenTop: number; +declare var screenX: number; +declare var screenY: number; +declare var scrollX: number; +declare var scrollY: number; +declare var scrollbars: BarProp; +declare var self: Window; +declare var status: string; +declare var statusbar: BarProp; +declare var styleMedia: StyleMedia; +declare var toolbar: BarProp; +declare var top: Window; +declare var window: Window; +declare var URL: URL; +declare function alert(message?: any): void; +declare function blur(): void; +declare function cancelAnimationFrame(handle: number): void; +declare function captureEvents(): void; +declare function close(): void; +declare function confirm(message?: string): boolean; +declare function focus(): void; +declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; +declare function getSelection(): Selection; +declare function matchMedia(mediaQuery: string): MediaQueryList; +declare function moveBy(x?: number, y?: number): void; +declare function moveTo(x?: number, y?: number): void; +declare function msCancelRequestAnimationFrame(handle: number): void; +declare function msMatchMedia(mediaQuery: string): MediaQueryList; +declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function postMessage(message: any, targetOrigin: string, ports?: any): void; +declare function print(): void; +declare function prompt(message?: string, _default?: string): string; +declare function releaseEvents(): void; +declare function requestAnimationFrame(callback: FrameRequestCallback): number; +declare function resizeBy(x?: number, y?: number): void; +declare function resizeTo(x?: number, y?: number): void; +declare function scroll(x?: number, y?: number): void; +declare function scrollBy(x?: number, y?: number): void; +declare function scrollTo(x?: number, y?: number): void; +declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; +declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; +declare function toString(): string; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function dispatchEvent(evt: Event): boolean; +declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function clearInterval(handle: number): void; +declare function clearTimeout(handle: number): void; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearImmediate(handle: number): void; +declare function msClearImmediate(handle: number): void; +declare function msSetImmediate(expression: any, ...args: any[]): number; +declare function setImmediate(expression: any, ...args: any[]): number; +declare var sessionStorage: Storage; +declare var localStorage: Storage; +declare var console: Console; +declare var onpointercancel: (ev: PointerEvent) => any; +declare var onpointerdown: (ev: PointerEvent) => any; +declare var onpointerenter: (ev: PointerEvent) => any; +declare var onpointerleave: (ev: PointerEvent) => any; +declare var onpointermove: (ev: PointerEvent) => any; +declare var onpointerout: (ev: PointerEvent) => any; +declare var onpointerover: (ev: PointerEvent) => any; +declare var onpointerup: (ev: PointerEvent) => any; +declare var onwheel: (ev: WheelEvent) => any; +declare var indexedDB: IDBFactory; +declare var msIndexedDB: IDBFactory; +declare function atob(encodedString: string): string; +declare function btoa(rawString: string): string; +declare function addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureHold", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSGestureTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSInertiaStart", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerCancel", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerDown", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerEnter", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerLeave", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerMove", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerOut", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerOver", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "MSPointerUp", listener: (ev: MSPointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "compassneedscalibration", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "contextmenu", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "hashchange", listener: (ev: HashChangeEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "orientationchange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "readystatechange", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; +declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;interface DOMTokenList { + [Symbol.iterator](): IterableIterator; +} + +interface NodeList { + [Symbol.iterator](): IterableIterator +} + +interface NodeListOf { + [Symbol.iterator](): IterableIterator +} + +///////////////////////////// +/// WorkerGlobalScope APIs +///////////////////////////// +// These are only available in a Web Worker +declare function importScripts(...urls: string[]): void; + + +///////////////////////////// +/// Windows Script Host APIS +///////////////////////////// + + +interface ActiveXObject { + new (s: string): any; +} +declare var ActiveXObject: ActiveXObject; + +interface ITextWriter { + Write(s: string): void; + WriteLine(s: string): void; + Close(): void; +} + +interface TextStreamBase { + /** + * The column number of the current character position in an input stream. + */ + Column: number; + + /** + * The current line number in an input stream. + */ + Line: number; + + /** + * Closes a text stream. + * It is not necessary to close standard streams; they close automatically when the process ends. If + * you close a standard stream, be aware that any other pointers to that standard stream become invalid. + */ + Close(): void; +} + +interface TextStreamWriter extends TextStreamBase { + /** + * Sends a string to an output stream. + */ + Write(s: string): void; + + /** + * Sends a specified number of blank lines (newline characters) to an output stream. + */ + WriteBlankLines(intLines: number): void; + + /** + * Sends a string followed by a newline character to an output stream. + */ + WriteLine(s: string): void; +} + +interface TextStreamReader extends TextStreamBase { + /** + * Returns a specified number of characters from an input stream, starting at the current pointer position. + * Does not return until the ENTER key is pressed. + * Can only be used on a stream in reading mode; causes an error in writing or appending mode. + */ + Read(characters: number): string; + + /** + * Returns all characters from an input stream. + * Can only be used on a stream in reading mode; causes an error in writing or appending mode. + */ + ReadAll(): string; + + /** + * Returns an entire line from an input stream. + * Although this method extracts the newline character, it does not add it to the returned string. + * Can only be used on a stream in reading mode; causes an error in writing or appending mode. + */ + ReadLine(): string; + + /** + * Skips a specified number of characters when reading from an input text stream. + * Can only be used on a stream in reading mode; causes an error in writing or appending mode. + * @param characters Positive number of characters to skip forward. (Backward skipping is not supported.) + */ + Skip(characters: number): void; + + /** + * Skips the next line when reading from an input text stream. + * Can only be used on a stream in reading mode, not writing or appending mode. + */ + SkipLine(): void; + + /** + * Indicates whether the stream pointer position is at the end of a line. + */ + AtEndOfLine: boolean; + + /** + * Indicates whether the stream pointer position is at the end of a stream. + */ + AtEndOfStream: boolean; +} + +declare var WScript: { + /** + * Outputs text to either a message box (under WScript.exe) or the command console window followed by + * a newline (under CScript.exe). + */ + Echo(s: any): void; + + /** + * Exposes the write-only error output stream for the current script. + * Can be accessed only while using CScript.exe. + */ + StdErr: TextStreamWriter; + + /** + * Exposes the write-only output stream for the current script. + * Can be accessed only while using CScript.exe. + */ + StdOut: TextStreamWriter; + Arguments: { length: number; Item(n: number): string; }; + + /** + * The full path of the currently running script. + */ + ScriptFullName: string; + + /** + * Forces the script to stop immediately, with an optional exit code. + */ + Quit(exitCode?: number): number; + + /** + * The Windows Script Host build version number. + */ + BuildVersion: number; + + /** + * Fully qualified path of the host executable. + */ + FullName: string; + + /** + * Gets/sets the script mode - interactive(true) or batch(false). + */ + Interactive: boolean; + + /** + * The name of the host executable (WScript.exe or CScript.exe). + */ + Name: string; + + /** + * Path of the directory containing the host executable. + */ + Path: string; + + /** + * The filename of the currently running script. + */ + ScriptName: string; + + /** + * Exposes the read-only input stream for the current script. + * Can be accessed only while using CScript.exe. + */ + StdIn: TextStreamReader; + + /** + * Windows Script Host version + */ + Version: string; + + /** + * Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event. + */ + ConnectObject(objEventSource: any, strPrefix: string): void; + + /** + * Creates a COM object. + * @param strProgiID + * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events. + */ + CreateObject(strProgID: string, strPrefix?: string): any; + + /** + * Disconnects a COM object from its event sources. + */ + DisconnectObject(obj: any): void; + + /** + * Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file. + * @param strPathname Fully qualified path to the file containing the object persisted to disk. + * For objects in memory, pass a zero-length string. + * @param strProgID + * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events. + */ + GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any; + + /** + * Suspends script execution for a specified length of time, then continues execution. + * @param intTime Interval (in milliseconds) to suspend script execution. + */ + Sleep(intTime: number): void; +}; + +/** + * Allows enumerating over a COM collection, which may not have indexed item access. + */ +interface Enumerator { + /** + * Returns true if the current item is the last one in the collection, or the collection is empty, + * or the current item is undefined. + */ + atEnd(): boolean; + + /** + * Returns the current item in the collection + */ + item(): T; + + /** + * Resets the current item in the collection to the first item. If there are no items in the collection, + * the current item is set to undefined. + */ + moveFirst(): void; + + /** + * Moves the current item to the next item in the collection. If the enumerator is at the end of + * the collection or the collection is empty, the current item is set to undefined. + */ + moveNext(): void; +} + +interface EnumeratorConstructor { + new (collection: any): Enumerator; + new (collection: any): Enumerator; +} + +declare var Enumerator: EnumeratorConstructor; + +/** + * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. + */ +interface VBArray { + /** + * Returns the number of dimensions (1-based). + */ + dimensions(): number; + + /** + * Takes an index for each dimension in the array, and returns the item at the corresponding location. + */ + getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T; + + /** + * Returns the smallest available index for a given dimension. + * @param dimension 1-based dimension (defaults to 1) + */ + lbound(dimension?: number): number; + + /** + * Returns the largest available index for a given dimension. + * @param dimension 1-based dimension (defaults to 1) + */ + ubound(dimension?: number): number; + + /** + * Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions, + * each successive dimension is appended to the end of the array. + * Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6] + */ + toArray(): T[]; +} + +interface VBArrayConstructor { + new (safeArray: any): VBArray; + new (safeArray: any): VBArray; +} + +declare var VBArray: VBArrayConstructor; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 33e0d0f9ded..43bc6fad9a0 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -492,7 +492,7 @@ interface IDBCursor { direction: string; key: any; primaryKey: any; - source: any; + source: IDBObjectStore | IDBIndex; advance(count: number): void; continue(key?: any): void; delete(): IDBRequest; @@ -530,7 +530,7 @@ interface IDBDatabase extends EventTarget { close(): void; createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; deleteObjectStore(name: string): void; - transaction(storeNames: any, mode?: string): IDBTransaction; + transaction(storeNames: string | string[], mode?: string): IDBTransaction; 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; @@ -588,9 +588,10 @@ declare var IDBKeyRange: { interface IDBObjectStore { indexNames: DOMStringList; - keyPath: string; + keyPath: string | string[]; name: string; transaction: IDBTransaction; + autoIncrement: boolean; add(value: any, key?: any): IDBRequest; clear(): IDBRequest; count(key?: any): IDBRequest; @@ -629,7 +630,7 @@ interface IDBRequest extends EventTarget { onsuccess: (ev: Event) => any; readyState: string; result: any; - source: any; + source: IDBObjectStore | IDBIndex | IDBCursor; transaction: IDBTransaction; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; @@ -1176,7 +1177,7 @@ interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; } interface DecodeErrorCallback { - (): void; + (error: DOMException): void; } interface FunctionStringCallback { (data: string): void; diff --git a/lib/tsc.js b/lib/tsc.js index 2208201fef0..4bdf0f84fae 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -46,6 +46,21 @@ 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"; + ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; + ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; + ModuleKind[ModuleKind["System"] = 4] = "System"; + ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; + ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; + })(ts.ModuleKind || (ts.ModuleKind = {})); + var ModuleKind = ts.ModuleKind; })(ts || (ts = {})); var ts; (function (ts) { @@ -410,6 +425,14 @@ var ts; }; } ts.createFileDiagnostic = createFileDiagnostic; + function formatMessage(dummy, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); + } + return text; + } + ts.formatMessage = formatMessage; function createCompilerDiagnostic(message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 1) { @@ -1042,7 +1065,7 @@ var ts; var filePath = typeof relativeFileName !== "string" ? undefined : ts.toPath(relativeFileName, baseDirPath, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); - if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) { + if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks.contains(filePath)) { for (var _i = 0, _a = fileWatcherCallbacks.get(filePath); _i < _a.length; _i++) { var fileCallback = _a[_i]; fileCallback(filePath); @@ -1058,7 +1081,7 @@ var ts; var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { + if (!fileExists(fileName)) { return undefined; } var buffer = _fs.readFileSync(fileName); @@ -1098,6 +1121,24 @@ var ts; function getCanonicalPath(path) { return useCaseSensitiveFileNames ? path : path.toLowerCase(); } + function fileSystemEntryExists(path, entryKind) { + try { + var stat = _fs.statSync(path); + switch (entryKind) { + case 0: return stat.isFile(); + case 1: return stat.isDirectory(); + } + } + catch (e) { + return false; + } + } + function fileExists(path) { + return fileSystemEntryExists(path, 0); + } + function directoryExists(path) { + return fileSystemEntryExists(path, 1); + } function readDirectory(path, extension, exclude) { var result = []; exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); @@ -1161,12 +1202,8 @@ var ts; resolvePath: function (path) { return _path.resolve(path); }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, + fileExists: fileExists, + directoryExists: directoryExists, createDirectory: function (directoryName) { if (!this.directoryExists(directoryName)) { _fs.mkdirSync(directoryName); @@ -1249,6 +1286,7 @@ var ts; An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_a_type_annotation_1021", message: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_must_have_a_type_annotation_1022", message: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_type_must_be_string_or_number_1023", message: "An index signature parameter type must be 'string' or 'number'." }, + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: { code: 1024, category: ts.DiagnosticCategory.Error, key: "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", message: "'readonly' modifier can only appear on a property declaration or index signature." }, Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility_modifier_already_seen_1028", message: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "_0_modifier_must_precede_1_modifier_1029", message: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "_0_modifier_already_seen_1030", message: "'{0}' modifier already seen." }, @@ -1262,7 +1300,7 @@ var ts; _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_a_class_declaration_1041", message: "'{0}' modifier cannot be used with a class declaration." }, _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_here_1042", message: "'{0}' modifier cannot be used here." }, _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_data_property_1043", message: "'{0}' modifier cannot appear on a data property." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_element_1044", message: "'{0}' modifier cannot appear on a module element." }, + _0_modifier_cannot_appear_on_a_module_or_namespace_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", message: "'{0}' modifier cannot appear on a module or namespace element." }, A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", message: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", message: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_be_optional_1047", message: "A rest parameter cannot be optional." }, @@ -1281,8 +1319,11 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum_member_must_have_initializer_1061", message: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_namespace_1063", message: "An export assignment cannot be used in a namespace." }, + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { code: 1064, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", message: "The return type of an async function or method must be the global Promise type." }, In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", message: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", message: "Unexpected token. A constructor, method, accessor, or property was expected." }, + _0_modifier_cannot_appear_on_a_type_member: { code: 1070, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_type_member_1070", message: "'{0}' modifier cannot appear on a type member." }, + _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, @@ -1338,10 +1379,9 @@ var ts; String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String_literal_expected_1141", message: "String literal expected." }, Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line_break_not_permitted_here_1142", message: "Line break not permitted here." }, or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers_not_permitted_on_index_signature_members_1145", message: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." }, Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." }, - Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_optio_1148", message: "Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file." }, + Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting__1148", message: "Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" }, @@ -1401,7 +1441,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Speci_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_6_or_higher_1220", message: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators_are_not_allowed_in_an_ambient_context_1221", message: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An_overload_signature_cannot_be_declared_as_a_generator_1222", message: "An overload signature cannot be declared as a generator." }, @@ -1410,6 +1450,7 @@ var ts; Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, @@ -1423,7 +1464,7 @@ var ts; Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", message: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", message: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", message: "Unable to resolve signature of method decorator when called as an expression." }, - abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_or_method_declaration_1242", message: "'abstract' modifier can only appear on a class or method declaration." }, + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", message: "'abstract' modifier can only appear on a class, method, or property declaration." }, _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_1_modifier_1243", message: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract_methods_can_only_appear_within_an_abstract_class_1244", message: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", message: "Method '{0}' cannot have an implementation because it is marked abstract." }, @@ -1516,7 +1557,7 @@ var ts; get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", message: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_not_exported_2383", message: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_exported_or_non_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_non_exported_2383", message: "Overload signatures must all be exported or non-exported." }, Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", message: "Overload signatures must all be ambient or non-ambient." }, Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_public_private_or_protected_2385", message: "Overload signatures must all be public, private or protected." }, Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_optional_or_required_2386", message: "Overload signatures must all be optional or required." }, @@ -1549,7 +1590,6 @@ var ts; Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class_name_cannot_be_0_2414", message: "Class name cannot be '{0}'" }, Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_extends_base_class_1_2415", message: "Class '{0}' incorrectly extends base class '{1}'." }, Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", message: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0_2419", message: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_implements_interface_1_2420", message: "Class '{0}' incorrectly implements interface '{1}'." }, A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_implement_another_class_or_interface_2422", message: "A class may only implement another class or interface." }, Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, @@ -1557,7 +1597,7 @@ var ts; Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface_name_cannot_be_0_2427", message: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_interface_must_have_identical_type_parameters_2428", message: "All declarations of an interface must have identical type parameters." }, + All_declarations_of_0_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_type_parameters_2428", message: "All declarations of '{0}' must have identical type parameters." }, Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface_0_incorrectly_extends_interface_1_2430", message: "Interface '{0}' incorrectly extends interface '{1}'." }, Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum_name_cannot_be_0_2431", message: "Enum name cannot be '{0}'" }, In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", message: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, @@ -1577,8 +1617,8 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_2449", message: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_2450", message: "Left-hand side of assignment expression cannot be a constant." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -1611,8 +1651,8 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant_2485", message: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant_2486", message: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, @@ -1638,7 +1678,7 @@ var ts; Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", message: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base_constructors_must_all_have_the_same_return_type_2510", message: "Base constructors must all have the same return type." }, Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot_create_an_instance_of_the_abstract_class_0_2511", message: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_not_abstract_2512", message: "Overload signatures must all be abstract or not abstract." }, + Overload_signatures_must_all_be_abstract_or_non_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", message: "Overload signatures must all be abstract or non-abstract." }, Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", message: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes_containing_abstract_methods_must_be_marked_abstract_2514", message: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", message: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, @@ -1654,6 +1694,8 @@ var ts; A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", message: "A 'this' type is available only in a non-static member of a class or interface." }, The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary_2527", message: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A_module_cannot_have_multiple_default_exports_2528", message: "A module cannot have multiple default exports." }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { code: 2529, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions." }, + Property_0_is_incompatible_with_index_signature: { code: 2530, category: ts.DiagnosticCategory.Error, key: "Property_0_is_incompatible_with_index_signature_2530", message: "Property '{0}' is incompatible with index signature." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1683,6 +1725,12 @@ var ts; export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { code: 2669, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", message: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations." }, Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { code: 2670, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", message: "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context." }, + Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { code: 2671, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671", message: "Cannot augment module '{0}' because it resolves to a non-module entity." }, + Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: { code: 2672, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_a_0_constructor_type_to_a_1_constructor_type_2672", message: "Cannot assign a '{0}' constructor type to a '{1}' constructor type." }, + Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: { code: 2673, category: ts.DiagnosticCategory.Error, key: "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673", message: "Constructor of class '{0}' is private and only accessible within the class declaration." }, + Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: { code: 2674, category: ts.DiagnosticCategory.Error, key: "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674", message: "Constructor of class '{0}' is protected and only accessible within the class declaration." }, + Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: { code: 2675, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_a_class_0_Class_constructor_is_marked_as_private_2675", message: "Cannot extend a class '{0}'. Class constructor is marked as private." }, + Accessors_must_both_be_abstract_or_non_abstract: { code: 2676, category: ts.DiagnosticCategory.Error, key: "Accessors_must_both_be_abstract_or_non_abstract_2676", message: "Accessors must both be abstract or non-abstract." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1771,7 +1819,10 @@ var ts; Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { code: 5056, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056", message: "Cannot write file '{0}' because it would be overwritten by multiple input files." }, Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { code: 5057, category: ts.DiagnosticCategory.Error, key: "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057", message: "Cannot find a tsconfig.json file at the specified directory: '{0}'" }, The_specified_path_does_not_exist_Colon_0: { code: 5058, category: ts.DiagnosticCategory.Error, key: "The_specified_path_does_not_exist_Colon_0_5058", message: "The specified path does not exist: '{0}'" }, - Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier: { code: 5059, category: ts.DiagnosticCategory.Error, key: "Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", message: "Invalide value for '--reactNamespace'. '{0}' is not a valid identifier." }, + Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: { code: 5059, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", message: "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier." }, + Option_paths_cannot_be_used_without_specifying_baseUrl_option: { code: 5060, category: ts.DiagnosticCategory.Error, key: "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", message: "Option 'paths' cannot be used without specifying '--baseUrl' option." }, + Pattern_0_can_have_at_most_one_Asterisk_character: { code: 5061, category: ts.DiagnosticCategory.Error, key: "Pattern_0_can_have_at_most_one_Asterisk_character_5061", message: "Pattern '{0}' can have at most one '*' character" }, + Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { code: 5062, category: ts.DiagnosticCategory.Error, key: "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", message: "Substitution '{0}' in pattern '{1}' in can have at most one '*' character" }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, 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_6003", message: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1805,7 +1856,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated_quoted_string_in_response_file_0_6045", message: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'none'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument_for_target_option_must_be_ES3_ES5_or_ES2015_6047", message: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", message: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported_locale_0_6049", message: "Unsupported locale '{0}'." }, @@ -1822,6 +1873,7 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, + Option_0_can_only_be_specified_in_tsconfig_json_file: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", message: "Option '{0}' can only be specified in 'tsconfig.json' file." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "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_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -1838,8 +1890,36 @@ var ts; Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "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_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, - Allow_javascript_files_to_be_compiled: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6083", message: "Allow javascript files to be compiled." }, + Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specifies the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Enable_tracing_of_the_module_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_module_resolution_process_6085", message: "Enable tracing of the module resolution process." }, + Resolving_module_0_from_1: { code: 6086, category: ts.DiagnosticCategory.Message, key: "Resolving_module_0_from_1_6086", message: "======== Resolving module '{0}' from '{1}'. ========" }, + Explicitly_specified_module_resolution_kind_Colon_0: { code: 6087, category: ts.DiagnosticCategory.Message, key: "Explicitly_specified_module_resolution_kind_Colon_0_6087", message: "Explicitly specified module resolution kind: '{0}'." }, + Module_resolution_kind_is_not_specified_using_0: { code: 6088, category: ts.DiagnosticCategory.Message, key: "Module_resolution_kind_is_not_specified_using_0_6088", message: "Module resolution kind is not specified, using '{0}'." }, + Module_name_0_was_successfully_resolved_to_1: { code: 6089, category: ts.DiagnosticCategory.Message, key: "Module_name_0_was_successfully_resolved_to_1_6089", message: "======== Module name '{0}' was successfully resolved to '{1}'. ========" }, + Module_name_0_was_not_resolved: { code: 6090, category: ts.DiagnosticCategory.Message, key: "Module_name_0_was_not_resolved_6090", message: "======== Module name '{0}' was not resolved. ========" }, + paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: { code: 6091, category: ts.DiagnosticCategory.Message, key: "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091", message: "'paths' option is specified, looking for a pattern to match module name '{0}'." }, + Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, + Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, + Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, + File_0_exist_use_it_as_a_module_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_module_resolution_result_6097", message: "File '{0}' exist - use it as a module resolution result." }, + Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, + package_json_does_not_have_typings_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_typings_field_6100", message: "'package.json' does not have 'typings' field." }, + package_json_has_typings_field_0_that_references_1: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_typings_field_0_that_references_1_6101", message: "'package.json' has 'typings' field '{0}' that references '{1}'." }, + Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, + Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, + Checking_if_0_is_the_longest_matching_prefix_for_1_2: { code: 6104, category: ts.DiagnosticCategory.Message, key: "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104", message: "Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'." }, + Expected_type_of_typings_field_in_package_json_to_be_string_got_0: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_typings_field_in_package_json_to_be_string_got_0_6105", message: "Expected type of 'typings' field in 'package.json' to be 'string', got '{0}'." }, + baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: { code: 6106, category: ts.DiagnosticCategory.Message, key: "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106", message: "'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'" }, + rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: { code: 6107, category: ts.DiagnosticCategory.Message, key: "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107", message: "'rootDirs' option is set, using it to resolve relative module name '{0}'" }, + Longest_matching_prefix_for_0_is_1: { code: 6108, category: ts.DiagnosticCategory.Message, key: "Longest_matching_prefix_for_0_is_1_6108", message: "Longest matching prefix for '{0}' is '{1}'" }, + Loading_0_from_the_root_dir_1_candidate_location_2: { code: 6109, category: ts.DiagnosticCategory.Message, key: "Loading_0_from_the_root_dir_1_candidate_location_2_6109", message: "Loading '{0}' from the root dir '{1}', candidate location '{2}'" }, + Trying_other_entries_in_rootDirs: { code: 6110, category: ts.DiagnosticCategory.Message, key: "Trying_other_entries_in_rootDirs_6110", message: "Trying other entries in 'rootDirs'" }, + Module_resolution_using_rootDirs_has_failed: { code: 6111, category: ts.DiagnosticCategory.Message, key: "Module_resolution_using_rootDirs_has_failed_6111", message: "Module resolution using 'rootDirs' has failed" }, + Do_not_emit_use_strict_directives_in_module_output: { code: 6112, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_use_strict_directives_in_module_output_6112", message: "Do not emit 'use strict' directives in module output." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -1878,7 +1958,6 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "property_declarations_can_only_be_used_in_a_ts_file_8014", message: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "enum_declarations_can_only_be_used_in_a_ts_file_8015", message: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", message: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "decorators_can_only_be_used_in_a_ts_file_8017", message: "'decorators' can only be used in a .ts file." }, Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -1889,7 +1968,8 @@ var ts; 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_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", message: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, - JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." } + JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." }, + super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." } }; })(ts || (ts = {})); var ts; @@ -1922,7 +2002,7 @@ var ts; "false": 84, "finally": 85, "for": 86, - "from": 133, + "from": 134, "function": 87, "get": 123, "if": 88, @@ -1937,25 +2017,26 @@ var ts; "namespace": 126, "new": 92, "null": 93, - "number": 128, + "number": 129, "package": 109, "private": 110, "protected": 111, "public": 112, - "require": 127, - "global": 134, + "readonly": 127, + "require": 128, + "global": 135, "return": 94, - "set": 129, + "set": 130, "static": 113, - "string": 130, + "string": 131, "super": 95, "switch": 96, - "symbol": 131, + "symbol": 132, "this": 97, "throw": 98, "true": 99, "try": 100, - "type": 132, + "type": 133, "typeof": 101, "var": 102, "void": 103, @@ -1964,7 +2045,7 @@ var ts; "yield": 114, "async": 118, "await": 119, - "of": 135, + "of": 136, "{": 15, "}": 16, "(": 17, @@ -2446,6 +2527,7 @@ var ts; scanJsxIdentifier: scanJsxIdentifier, reScanJsxToken: reScanJsxToken, scanJsxToken: scanJsxToken, + scanJSDocToken: scanJSDocToken, scan: scan, setText: setText, setScriptTarget: setScriptTarget, @@ -2453,7 +2535,8 @@ var ts; setOnError: setOnError, setTextPos: setTextPos, tryScan: tryScan, - lookAhead: lookAhead + lookAhead: lookAhead, + scanRange: scanRange }; function error(message, length) { if (onError) { @@ -3225,7 +3308,7 @@ var ts; break; } } - return token = 239; + return token = 240; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -3243,6 +3326,54 @@ var ts; } return token; } + function scanJSDocToken() { + if (pos >= end) { + return token = 1; + } + startPos = pos; + var ch = text.charCodeAt(pos); + while (pos < end) { + ch = text.charCodeAt(pos); + if (isWhiteSpace(ch)) { + pos++; + } + else { + break; + } + } + tokenPos = pos; + switch (ch) { + case 64: + return pos += 1, token = 55; + case 10: + case 13: + return pos += 1, token = 4; + case 42: + return pos += 1, token = 37; + case 123: + return pos += 1, token = 15; + case 125: + return pos += 1, token = 16; + case 91: + return pos += 1, token = 19; + case 93: + return pos += 1, token = 20; + case 61: + return pos += 1, token = 56; + case 44: + return pos += 1, token = 24; + } + if (isIdentifierStart(ch, 2)) { + pos++; + while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { + pos++; + } + return token = 69; + } + else { + return pos += 1, token = 0; + } + } function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; @@ -3261,6 +3392,29 @@ var ts; } return result; } + function scanRange(start, length, callback) { + var saveEnd = end; + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var savePrecedingLineBreak = precedingLineBreak; + var saveTokenValue = tokenValue; + var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; + var saveTokenIsUnterminated = tokenIsUnterminated; + setText(text, start, length); + var result = callback(); + end = saveEnd; + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + precedingLineBreak = savePrecedingLineBreak; + tokenValue = saveTokenValue; + hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; + tokenIsUnterminated = saveTokenIsUnterminated; + return result; + } function lookAhead(callback) { return speculationHelper(callback, true); } @@ -3377,26 +3531,38 @@ var ts; ts.setResolvedModule = setResolvedModule; function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 64) !== 0; + return (node.flags & 268435456) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 128)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || + if (!(node.flags & 536870912)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 67108864) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 64; + node.flags |= 268435456; } - node.parserContextFlags |= 128; + node.flags |= 536870912; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 251) { + while (node && node.kind !== 252) { node = node.parent; } return node; } ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 196: + case 224: + case 203: + case 204: + case 205: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; function getStartPositionOfLine(line, sourceFile) { ts.Debug.assert(line >= 0); return ts.getLineStarts(sourceFile)[line]; @@ -3471,17 +3637,24 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 24576) !== 0 || + return (getCombinedNodeFlags(declaration) & 3072) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 221 && + return node && node.kind === 222 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; + function isBlockScopedContainerTopLevel(node) { + return node.kind === 252 || + node.kind === 222 || + isFunctionLike(node) || + isFunctionBlock(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 2097152); + return !!(module.flags & 131072); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -3489,9 +3662,9 @@ var ts; return false; } switch (node.parent.kind) { - case 251: + case 252: return isExternalModule(node.parent); - case 222: + case 223: return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); } return false; @@ -3504,15 +3677,15 @@ var ts; return current; } switch (current.kind) { - case 251: - case 223: - case 247: - case 221: - case 202: + case 252: + case 224: + case 248: + case 222: case 203: case 204: + case 205: return current; - case 195: + case 196: if (!isFunctionLike(current.parent)) { return current; } @@ -3523,9 +3696,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 214 && + declaration.kind === 215 && declaration.parent && - declaration.parent.kind === 247; + declaration.parent.kind === 248; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3561,24 +3734,26 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 251: + case 252: 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 214: - case 166: - case 217: - case 189: + case 215: + case 167: case 218: - case 221: - case 220: - case 250: - case 216: - case 176: - case 144: + case 190: case 219: + case 222: + case 221: + case 251: + case 217: + case 177: + case 145: + case 147: + case 148: + case 220: errorNode = node.name; break; } @@ -3600,15 +3775,15 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { - return (file.flags & 4096) !== 0; + return file.isDeclarationFile; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 220 && isConst(node); + return node.kind === 221 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 166 || isBindingPattern(node))) { + while (node && (node.kind === 167 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3616,29 +3791,33 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 214) { + if (node.kind === 215) { node = node.parent; } - if (node && node.kind === 215) { + if (node && node.kind === 216) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 196) { + if (node && node.kind === 197) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 16384); + return !!(getCombinedNodeFlags(node) & 2048); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 8192); + return !!(getCombinedNodeFlags(node) & 1024); } ts.isLet = isLet; + function isSuperCallExpression(n) { + return n.kind === 172 && n.expression.kind === 95; + } + ts.isSuperCallExpression = isSuperCallExpression; function isPrologueDirective(node) { - return node.kind === 198 && node.expression.kind === 9; + return node.kind === 199 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -3654,7 +3833,7 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 139 || node.kind === 138) ? + var commentRanges = (node.kind === 140 || node.kind === 139) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -3668,67 +3847,67 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (151 <= node.kind && node.kind <= 163) { + if (152 <= node.kind && node.kind <= 164) { return true; } switch (node.kind) { case 117: - case 128: - case 130: - case 120: + case 129: case 131: + case 120: + case 132: return true; case 103: - return node.parent.kind !== 180; - case 191: + return node.parent.kind !== 181; + case 192: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 69: - if (node.parent.kind === 136 && node.parent.right === node) { + if (node.parent.kind === 137 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 169 && node.parent.name === node) { + else if (node.parent.kind === 170 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 69 || node.kind === 136 || node.kind === 169, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 136: - case 169: + ts.Debug.assert(node.kind === 69 || node.kind === 137 || node.kind === 170, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 137: + case 170: case 97: var parent_1 = node.parent; - if (parent_1.kind === 155) { + if (parent_1.kind === 156) { return false; } - if (151 <= parent_1.kind && parent_1.kind <= 163) { + if (152 <= parent_1.kind && parent_1.kind <= 164) { return true; } switch (parent_1.kind) { - case 191: + case 192: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 138: - return node === parent_1.constraint; - case 142: - case 141: case 139: - case 214: + return node === parent_1.constraint; + case 143: + case 142: + case 140: + case 215: return node === parent_1.type; - case 216: - case 176: + case 217: case 177: + case 178: + case 146: case 145: case 144: - case 143: - case 146: case 147: - return node === parent_1.type; case 148: + return node === parent_1.type; case 149: case 150: + case 151: return node === parent_1.type; - case 174: + case 175: return node === parent_1.type; - case 171: case 172: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 173: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 174: return false; } } @@ -3739,23 +3918,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 207: + case 208: return visitor(node); - case 223: - case 195: - case 199: + case 224: + case 196: case 200: case 201: case 202: case 203: case 204: - case 208: + case 205: case 209: - case 244: - case 245: case 210: - case 212: - case 247: + case 245: + case 246: + case 211: + case 213: + case 248: return ts.forEachChild(node, traverse); } } @@ -3765,23 +3944,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 187: + case 188: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 220: - case 218: case 221: case 219: - case 217: - case 189: + case 222: + case 220: + case 218: + case 190: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 137) { + if (name_5 && name_5.kind === 138) { traverse(name_5.expression); return; } @@ -3796,14 +3975,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 166: - case 250: - case 139: - case 248: - case 142: - case 141: + case 167: + case 251: + case 140: case 249: - case 214: + case 143: + case 142: + case 250: + case 215: return true; } } @@ -3811,11 +3990,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 146 || node.kind === 147); + return node && (node.kind === 147 || node.kind === 148); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 217 || node.kind === 189); + return node && (node.kind === 218 || node.kind === 190); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -3824,32 +4003,32 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 145: - case 176: - case 216: - case 177: - case 144: - case 143: case 146: + case 177: + case 217: + case 178: + case 145: + case 144: case 147: case 148: case 149: case 150: - case 153: + case 151: case 154: + case 155: return true; } } ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 144: - case 143: case 145: + case 144: case 146: case 147: - case 216: - case 176: + case 148: + case 217: + case 177: return true; } return false; @@ -3857,30 +4036,34 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 202: case 203: case 204: - case 200: + case 205: case 201: + case 202: return true; - case 210: + case 211: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 195 && isFunctionLike(node.parent); + return node && node.kind === 196 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 144 && node.parent.kind === 168; + return node && node.kind === 145 && node.parent.kind === 169; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0; + } + ts.isThisTypePredicate = isThisTypePredicate; function getContainingFunction(node) { while (true) { node = node.parent; @@ -3906,39 +4089,39 @@ var ts; return undefined; } switch (node.kind) { - case 137: + case 138: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 140: - if (node.parent.kind === 139 && isClassElement(node.parent.parent)) { + case 141: + if (node.parent.kind === 140 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 177: + case 178: if (!includeArrowFunctions) { continue; } - case 216: - case 176: - case 221: - case 142: - case 141: - case 144: + case 217: + case 177: + case 222: case 143: + case 142: case 145: + case 144: case 146: case 147: case 148: case 149: case 150: - case 220: - case 251: + case 151: + case 221: + case 252: return node; } } @@ -3951,25 +4134,25 @@ var ts; return node; } switch (node.kind) { - case 137: + case 138: node = node.parent; break; - case 216: - case 176: + case 217: case 177: + case 178: if (!stopOnFunctions) { continue; } - case 142: - case 141: - case 144: case 143: + case 142: case 145: + case 144: case 146: case 147: + case 148: return node; - case 140: - if (node.parent.kind === 139 && isClassElement(node.parent.parent)) { + case 141: + if (node.parent.kind === 140 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -3980,15 +4163,21 @@ var ts; } } ts.getSuperContainer = getSuperContainer; + function isSuperPropertyOrElementAccess(node) { + return (node.kind === 170 + || node.kind === 171) + && node.expression.kind === 95; + } + ts.isSuperPropertyOrElementAccess = isSuperPropertyOrElementAccess; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 152: + case 153: return node.typeName; - case 191: + case 192: return node.expression; case 69: - case 136: + case 137: return node; } } @@ -3996,7 +4185,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 173) { + if (node.kind === 174) { return node.tag; } return node.expression; @@ -4004,21 +4193,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 217: + case 218: return true; - case 142: - return node.parent.kind === 217; - case 146: + case 143: + return node.parent.kind === 218; case 147: - case 144: + case 148: + case 145: return node.body !== undefined - && node.parent.kind === 217; - case 139: + && node.parent.kind === 218; + case 140: return node.parent.body !== undefined - && (node.parent.kind === 145 - || node.parent.kind === 144 - || node.parent.kind === 147) - && node.parent.parent.kind === 217; + && (node.parent.kind === 146 + || node.parent.kind === 145 + || node.parent.kind === 148) + && node.parent.parent.kind === 218; } return false; } @@ -4029,11 +4218,11 @@ var ts; } ts.nodeIsDecorated = nodeIsDecorated; function isPropertyAccessExpression(node) { - return node.kind === 169; + return node.kind === 170; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 170; + return node.kind === 171; } ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { @@ -4043,42 +4232,42 @@ var ts; case 99: case 84: case 10: - case 167: case 168: case 169: case 170: case 171: case 172: case 173: - case 192: case 174: + case 193: case 175: case 176: - case 189: case 177: - case 180: + case 190: case 178: + case 181: case 179: - case 182: + case 180: case 183: case 184: case 185: - case 188: case 186: - case 11: - case 190: - case 236: - case 237: + case 189: case 187: - case 181: + case 11: + case 191: + case 237: + case 238: + case 188: + case 182: return true; - case 136: - while (node.parent.kind === 136) { + case 137: + while (node.parent.kind === 137) { node = node.parent; } - return node.parent.kind === 155; + return node.parent.kind === 156; case 69: - if (node.parent.kind === 155) { + if (node.parent.kind === 156) { return true; } case 8: @@ -4086,47 +4275,47 @@ var ts; case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 214: - case 139: + case 215: + case 140: + case 143: case 142: - case 141: - case 250: - case 248: - case 166: + case 251: + case 249: + case 167: return parent_2.initializer === node; - case 198: case 199: case 200: case 201: - case 207: + case 202: case 208: case 209: - case 244: - case 211: - case 209: + case 210: + case 245: + case 212: + case 210: return parent_2.expression === node; - case 202: + case 203: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 215) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 216) || forStatement.condition === node || forStatement.incrementor === node; - case 203: case 204: + case 205: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 215) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 216) || forInStatement.expression === node; - case 174: - case 192: - return node === parent_2.expression; + case 175: case 193: return node === parent_2.expression; - case 137: + case 194: return node === parent_2.expression; - case 140: + case 138: + return node === parent_2.expression; + case 141: + case 244: case 243: - case 242: return true; - case 191: + case 192: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4148,7 +4337,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 224 && node.moduleReference.kind === 235; + return node.kind === 225 && node.moduleReference.kind === 236; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4157,7 +4346,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 224 && node.moduleReference.kind !== 235; + return node.kind === 225 && node.moduleReference.kind !== 236; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -4165,23 +4354,23 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.parserContextFlags & 32); + return node && !!(node.flags & 134217728); } ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression) { - return expression.kind === 171 && + function isRequireCall(expression, checkArgumentIsStringLiteral) { + var isRequire = expression.kind === 172 && expression.expression.kind === 69 && expression.expression.text === "require" && - expression.arguments.length === 1 && - expression.arguments[0].kind === 9; + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); } ts.isRequireCall = isRequireCall; function getSpecialPropertyAssignmentKind(expression) { - if (expression.kind !== 184) { + if (expression.kind !== 185) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 169) { + if (expr.operatorToken.kind !== 56 || expr.left.kind !== 170) { return 0; } var lhs = expr.left; @@ -4197,7 +4386,7 @@ var ts; else if (lhs.expression.kind === 97) { return 4; } - else if (lhs.expression.kind === 169) { + else if (lhs.expression.kind === 170) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 69 && innerPropertyAccess.name.text === "prototype") { return 3; @@ -4207,19 +4396,19 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 225) { + if (node.kind === 226) { return node.moduleSpecifier; } - if (node.kind === 224) { + if (node.kind === 225) { var reference = node.moduleReference; - if (reference.kind === 235) { + if (reference.kind === 236) { return reference.expression; } } - if (node.kind === 231) { + if (node.kind === 232) { return node.moduleSpecifier; } - if (node.kind === 221 && node.name.kind === 9) { + if (node.kind === 222 && node.name.kind === 9) { return node.name; } } @@ -4227,13 +4416,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 139: + case 140: + case 145: case 144: - case 143: + case 250: case 249: - case 248: + case 143: case 142: - case 141: return node.questionToken !== undefined; } } @@ -4241,49 +4430,83 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 264 && + return node.kind === 265 && node.parameters.length > 0 && - node.parameters[0].type.kind === 266; + node.parameters[0].type.kind === 267; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind) { - if (node && node.jsDocComment) { - for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.kind === kind) { - return tag; - } + function getJSDocTag(node, kind, checkParentVariableStatement) { + if (!node) { + return undefined; + } + var jsDocComment = getJSDocComment(node, checkParentVariableStatement); + if (!jsDocComment) { + return undefined; + } + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === kind) { + return tag; } } } + function getJSDocComment(node, checkParentVariableStatement) { + if (node.jsDocComment) { + return node.jsDocComment; + } + if (checkParentVariableStatement) { + var isInitializerOfVariableDeclarationInStatement = node.parent.kind === 215 && + node.parent.initializer === node && + node.parent.parent.parent.kind === 197; + var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; + if (variableStatementNode) { + return variableStatementNode.jsDocComment; + } + var parent_3 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_3 && parent_3.parent && + parent_3.kind === 185 && + parent_3.operatorToken.kind === 56 && + parent_3.parent.kind === 199; + if (isSourceOfAssignmentExpressionStatement) { + return parent_3.parent.jsDocComment; + } + var isPropertyAssignmentExpression = parent_3 && parent_3.kind === 249; + if (isPropertyAssignmentExpression) { + return parent_3.jsDocComment; + } + } + return undefined; + } function getJSDocTypeTag(node) { - return getJSDocTag(node, 272); + return getJSDocTag(node, 273, false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 271); + return getJSDocTag(node, 272, true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 273); + return getJSDocTag(node, 274, false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { if (parameter.name && parameter.name.kind === 69) { var parameterName = parameter.name.text; - var docComment = parameter.parent.jsDocComment; - if (docComment) { - return ts.forEach(docComment.tags, function (t) { - if (t.kind === 270) { - var parameterTag = t; + var jsDocComment = getJSDocComment(parameter.parent, true); + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === 271) { + var parameterTag = tag; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { - return t; + return parameterTag; } } - }); + } } } + return undefined; } ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; function hasRestParameter(s) { @@ -4292,13 +4515,13 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { if (node) { - if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 265) { + if (node.flags & 134217728) { + if (node.type && node.type.kind === 266) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 265; + return paramTag.typeExpression.type.kind === 266; } } return node.dotDotDotToken !== undefined; @@ -4319,7 +4542,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 165 || node.kind === 164); + return !!node && (node.kind === 166 || node.kind === 165); } ts.isBindingPattern = isBindingPattern; function isNodeDescendentOf(node, ancestor) { @@ -4333,7 +4556,7 @@ var ts; ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (4 | 4096)) { + if (node.flags & 2 || (node.kind === 252 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -4343,34 +4566,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 177: - case 166: - case 217: - case 189: - case 145: - case 220: - case 250: - case 233: - case 216: - case 176: - case 146: - case 226: - case 224: - case 229: + case 178: + case 167: case 218: - case 144: - case 143: + case 190: + case 146: case 221: - case 227: - case 139: - case 248: - case 142: - case 141: + case 251: + case 234: + case 217: + case 177: case 147: - case 249: + case 227: + case 225: + case 230: case 219: - case 138: - case 214: + case 145: + case 144: + case 222: + case 228: + case 140: + case 249: + case 143: + case 142: + case 148: + case 250: + case 220: + case 139: + case 215: return true; } return false; @@ -4378,25 +4601,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 206: - case 205: - case 213: - case 200: - case 198: - case 197: - case 203: - case 204: - case 202: - case 199: - case 210: case 207: - case 209: - case 211: - case 212: - case 196: + case 206: + case 214: case 201: + case 199: + case 198: + case 204: + case 205: + case 203: + case 200: + case 211: case 208: - case 230: + case 210: + case 212: + case 213: + case 197: + case 202: + case 209: + case 231: return true; default: return false; @@ -4405,13 +4628,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 145: - case 142: - case 144: case 146: - case 147: case 143: - case 150: + case 145: + case 147: + case 148: + case 144: + case 151: return true; default: return false; @@ -4423,7 +4646,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 229 || parent.kind === 233) { + if (parent.kind === 230 || parent.kind === 234) { if (parent.propertyName) { return true; } @@ -4437,40 +4660,40 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 142: - case 141: - case 144: case 143: - case 146: + case 142: + case 145: + case 144: case 147: - case 250: - case 248: - case 169: + case 148: + case 251: + case 249: + case 170: return parent.name === node; - case 136: + case 137: if (parent.right === node) { - while (parent.kind === 136) { + while (parent.kind === 137) { parent = parent.parent; } - return parent.kind === 155; + return parent.kind === 156; } return false; - case 166: - case 229: + case 167: + case 230: return parent.propertyName === node; - case 233: + case 234: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 224 || - node.kind === 226 && !!node.name || - node.kind === 227 || - node.kind === 229 || - node.kind === 233 || - node.kind === 230 && node.expression.kind === 69; + return node.kind === 225 || + node.kind === 227 && !!node.name || + node.kind === 228 || + node.kind === 230 || + node.kind === 234 || + node.kind === 231 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -4552,7 +4775,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 <= token && token <= 135; + return 70 <= token && token <= 136; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -4572,7 +4795,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 137 && + return name.kind === 138 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -4585,7 +4808,7 @@ var ts; if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 137) { + if (name.kind === 138) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4614,6 +4837,7 @@ var ts; case 112: case 110: case 111: + case 127: case 113: return true; } @@ -4622,18 +4846,18 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 139; + return root.kind === 140; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 166) { + while (node.kind === 167) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 221 || n.kind === 251; + return isFunctionLike(n) || n.kind === 222 || n.kind === 252; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneNode(node, location, flags, parent) { @@ -4666,7 +4890,7 @@ var ts; } ts.cloneEntityName = cloneEntityName; function isQualifiedName(node) { - return node.kind === 136; + return node.kind === 137; } ts.isQualifiedName = isQualifiedName; function nodeIsSynthesized(node) { @@ -4907,9 +5131,9 @@ var ts; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { - return compilerOptions.module ? + return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? 5 : 0; + getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function forEachExpectedEmitFile(host, action, targetSourceFile) { @@ -4927,7 +5151,18 @@ var ts; } } function onSingleFileEmit(host, sourceFile) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, sourceFile.languageVariant === 1 && options.jsx === 1 ? ".jsx" : ".js"); + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); var emitFileNames = { jsFilePath: jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), @@ -4979,7 +5214,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 145 && nodeIsPresent(member.body)) { + if (member.kind === 146 && nodeIsPresent(member.body)) { return member; } }); @@ -4996,10 +5231,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 146) { + if (accessor.kind === 147) { getAccessor = accessor; } - else if (accessor.kind === 147) { + else if (accessor.kind === 148) { setAccessor = accessor; } else { @@ -5008,8 +5243,8 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 146 || member.kind === 147) - && (member.flags & 64) === (accessor.flags & 64)) { + if ((member.kind === 147 || member.kind === 148) + && (member.flags & 32) === (accessor.flags & 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -5019,10 +5254,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 146 && !getAccessor) { + if (member.kind === 147 && !getAccessor) { getAccessor = member; } - if (member.kind === 147 && !setAccessor) { + if (member.kind === 148 && !setAccessor) { setAccessor = member; } } @@ -5171,16 +5406,17 @@ var ts; } function modifierToFlag(token) { switch (token) { - case 113: return 64; - case 112: return 8; - case 111: return 32; - case 110: return 16; + case 113: return 32; + case 112: return 4; + case 111: return 16; + case 110: return 8; case 115: return 128; - case 82: return 2; - case 122: return 4; - case 74: return 16384; + case 82: return 1; + case 122: return 2; + case 74: return 2048; case 77: return 512; case 118: return 256; + case 127: return 64; } return 0; } @@ -5188,24 +5424,24 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 169: case 170: - case 172: case 171: - case 236: - case 237: case 173: - case 167: - case 175: + case 172: + case 237: + case 238: + case 174: case 168: - case 189: case 176: + case 169: + case 190: + case 177: case 69: case 10: case 8: case 9: case 11: - case 186: + case 187: case 84: case 93: case 97: @@ -5222,7 +5458,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 191 && + return node.kind === 192 && node.parent.token === 83 && isClassLike(node.parent.parent); } @@ -5243,16 +5479,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 136 && node.parent.right === node) || - (node.parent.kind === 169 && node.parent.name === node); + return (node.parent.kind === 137 && node.parent.right === node) || + (node.parent.kind === 170 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 168) { + if (kind === 169) { return expression.properties.length === 0; } - if (kind === 167) { + if (kind === 168) { return expression.elements.length === 0; } return false; @@ -5496,9 +5732,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 138) { + if (d && d.kind === 139) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 218) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 219) { return current; } } @@ -5506,7 +5742,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return node.flags & 56 && node.parent.kind === 145 && ts.isClassLike(node.parent.parent); + return node.flags & 28 && node.parent.kind === 146 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; })(ts || (ts = {})); @@ -5516,7 +5752,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 251) { + if (kind === 252) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else { @@ -5552,26 +5788,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 136: + case 137: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 138: + case 139: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 249: + case 250: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 139: + case 140: + case 143: case 142: - case 141: - case 248: - case 214: - case 166: + case 249: + case 215: + case 167: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5580,24 +5816,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 153: case 154: - case 148: + case 155: case 149: case 150: + case 151: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 144: - case 143: case 145: + case 144: case 146: case 147: - case 176: - case 216: + case 148: case 177: + case 217: + case 178: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5608,160 +5844,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 152: + case 153: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 151: + case 152: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 155: - return visitNode(cbNode, node.exprName); case 156: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 157: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 158: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 159: + return visitNodes(cbNodes, node.elementTypes); case 160: - return visitNodes(cbNodes, node.types); case 161: + return visitNodes(cbNodes, node.types); + case 162: return visitNode(cbNode, node.type); - case 164: case 165: - return visitNodes(cbNodes, node.elements); - case 167: + case 166: return visitNodes(cbNodes, node.elements); case 168: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 169: + return visitNodes(cbNodes, node.properties); + case 170: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 170: + case 171: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 171: case 172: + case 173: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 173: + case 174: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 174: + case 175: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 175: - return visitNode(cbNode, node.expression); - case 178: + case 176: return visitNode(cbNode, node.expression); case 179: return visitNode(cbNode, node.expression); case 180: return visitNode(cbNode, node.expression); - case 182: - return visitNode(cbNode, node.operand); - case 187: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 181: return visitNode(cbNode, node.expression); case 183: return visitNode(cbNode, node.operand); + case 188: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 182: + return visitNode(cbNode, node.expression); case 184: + return visitNode(cbNode, node.operand); + case 185: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 192: + case 193: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 185: + case 186: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 188: + case 189: return visitNode(cbNode, node.expression); - case 195: - case 222: + case 196: + case 223: return visitNodes(cbNodes, node.statements); - case 251: + case 252: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 196: + case 197: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 215: + case 216: return visitNodes(cbNodes, node.declarations); - case 198: - return visitNode(cbNode, node.expression); case 199: + return visitNode(cbNode, node.expression); + case 200: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 200: + case 201: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 201: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 202: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 203: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 204: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 205: - case 206: - return visitNode(cbNode, node.label); - case 207: - return visitNode(cbNode, node.expression); - case 208: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 206: + case 207: + return visitNode(cbNode, node.label); + case 208: + return visitNode(cbNode, node.expression); case 209: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 223: + case 224: return visitNodes(cbNodes, node.clauses); - case 244: + case 245: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 245: + case 246: return visitNodes(cbNodes, node.statements); - case 210: + case 211: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 211: - return visitNode(cbNode, node.expression); case 212: + return visitNode(cbNode, node.expression); + case 213: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 247: + case 248: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 140: + case 141: return visitNode(cbNode, node.expression); - case 217: - case 189: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 218: + case 190: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -5773,137 +6002,160 @@ 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 220: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 250: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 221: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 251: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 222: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 226: + case 227: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 227: - return visitNode(cbNode, node.name); case 228: - case 232: + return visitNode(cbNode, node.name); + case 229: + case 233: return visitNodes(cbNodes, node.elements); - case 231: + case 232: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 229: - case 233: + case 230: + case 234: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 230: + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 186: + case 187: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 193: + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 137: + case 138: return visitNode(cbNode, node.expression); - case 246: + case 247: return visitNodes(cbNodes, node.types); - case 191: + case 192: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 235: - return visitNode(cbNode, node.expression); - case 234: - return visitNodes(cbNodes, node.decorators); case 236: + return visitNode(cbNode, node.expression); + case 235: + return visitNodes(cbNodes, node.decorators); + case 237: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 237: case 238: + case 239: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 241: + case 242: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 242: - return visitNode(cbNode, node.expression); case 243: return visitNode(cbNode, node.expression); - case 240: + case 244: + return visitNode(cbNode, node.expression); + case 241: return visitNode(cbNode, node.tagName); - case 252: + case 253: return visitNode(cbNode, node.type); - case 256: - return visitNodes(cbNodes, node.types); case 257: return visitNodes(cbNodes, node.types); - case 255: + case 258: + return visitNodes(cbNodes, node.types); + case 256: return visitNode(cbNode, node.elementType); + case 260: + return visitNode(cbNode, node.type); case 259: return visitNode(cbNode, node.type); - case 258: - return visitNode(cbNode, node.type); - case 260: + case 261: return visitNodes(cbNodes, node.members); - case 262: + case 263: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 263: - return visitNode(cbNode, node.type); case 264: + return visitNode(cbNode, node.type); + case 265: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 265: - return visitNode(cbNode, node.type); case 266: return visitNode(cbNode, node.type); case 267: return visitNode(cbNode, node.type); - case 261: + case 268: + return visitNode(cbNode, node.type); + case 262: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 268: + case 269: return visitNodes(cbNodes, node.tags); - case 270: + case 271: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 271: - return visitNode(cbNode, node.typeExpression); case 272: return visitNode(cbNode, node.typeExpression); case 273: + return visitNode(cbNode, node.typeExpression); + case 274: return visitNodes(cbNodes, node.typeParameters); } } ts.forEachChild = forEachChild; - function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { + function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { 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, undefined, setParentNodes, scriptKind); ts.parseTime += new Date().getTime() - start; return result; } ts.createSourceFile = createSourceFile; + function getScriptKindFromFileName(fileName) { + var ext = fileName.substr(fileName.lastIndexOf(".")); + switch (ext.toLowerCase()) { + case ".js": + return 1; + case ".jsx": + return 2; + case ".ts": + return 3; + case ".tsx": + return 4; + default: + return 3; + } + } + ts.getScriptKindFromFileName = getScriptKindFromFileName; function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); } @@ -5919,7 +6171,7 @@ var ts; var Parser; (function (Parser) { var scanner = ts.createScanner(2, true); - var disallowInAndDecoratorContext = 1 | 4; + var disallowInAndDecoratorContext = 4194304 | 16777216; var NodeConstructor; var SourceFileConstructor; var sourceFile; @@ -5933,18 +6185,18 @@ var ts; var parsingContext; var contextFlags; var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; - initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); - var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); + function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName); + initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function getLanguageVariant(fileName) { - return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx") ? 1 : 0; + function getLanguageVariant(scriptKind) { + return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } - function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor(); sourceText = _sourceText; @@ -5954,12 +6206,12 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = isJavaScriptFile ? 32 : 0; + contextFlags = scriptKind === 1 || scriptKind === 2 ? 134217728 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(getLanguageVariant(fileName)); + scanner.setLanguageVariant(getLanguageVariant(scriptKind)); } function clearState() { scanner.setText(""); @@ -5970,11 +6222,9 @@ var ts; syntaxCursor = undefined; sourceText = undefined; } - function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { - sourceFile = createSourceFile(fileName, languageVersion); - if (contextFlags & 32) { - sourceFile.parserContextFlags = 32; - } + function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { + sourceFile = createSourceFile(fileName, languageVersion, scriptKind); + sourceFile.flags = contextFlags; token = nextToken(); processReferenceComments(sourceFile); sourceFile.statements = parseList(0, parseStatement); @@ -5988,35 +6238,22 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - if (ts.isSourceFileJavaScript(sourceFile)) { - addJSDocComments(); - } return sourceFile; } - function addJSDocComments() { - forEachChild(sourceFile, visit); - return; - function visit(node) { - switch (node.kind) { - case 196: - case 216: - case 139: - addJSDocComment(node); - } - forEachChild(node, visit); - } - } function addJSDocComment(node) { - var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (jsDocComment) { - node.jsDocComment = jsDocComment; + if (contextFlags & 134217728) { + var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (jsDocComment) { + node.jsDocComment = jsDocComment; + } } } } + return node; } function fixupParentReferences(sourceFile) { var parent = sourceFile; @@ -6033,15 +6270,16 @@ var ts; } } Parser.fixupParentReferences = fixupParentReferences; - function createSourceFile(fileName, languageVersion) { - var sourceFile = new SourceFileConstructor(251, 0, sourceText.length); + function createSourceFile(fileName, languageVersion, scriptKind) { + var sourceFile = new SourceFileConstructor(252, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 : 0; - sourceFile.languageVariant = getLanguageVariant(sourceFile.fileName); + sourceFile.languageVariant = getLanguageVariant(scriptKind); + sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts"); + sourceFile.scriptKind = scriptKind; return sourceFile; } function setContextFlag(val, flag) { @@ -6053,16 +6291,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 1); + setContextFlag(val, 4194304); } function setYieldContext(val) { - setContextFlag(val, 2); + setContextFlag(val, 8388608); } function setDecoratorContext(val) { - setContextFlag(val, 4); + setContextFlag(val, 16777216); } function setAwaitContext(val) { - setContextFlag(val, 8); + setContextFlag(val, 33554432); } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; @@ -6085,40 +6323,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(1, func); + return doOutsideOfContext(4194304, func); } function disallowInAnd(func) { - return doInsideOfContext(1, func); + return doInsideOfContext(4194304, func); } function doInYieldContext(func) { - return doInsideOfContext(2, func); + return doInsideOfContext(8388608, func); } function doInDecoratorContext(func) { - return doInsideOfContext(4, func); + return doInsideOfContext(16777216, func); } function doInAwaitContext(func) { - return doInsideOfContext(8, func); + return doInsideOfContext(33554432, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(8, func); + return doOutsideOfContext(33554432, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(2 | 8, func); + return doInsideOfContext(8388608 | 33554432, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(2); + return inContext(8388608); } function inDisallowInContext() { - return inContext(1); + return inContext(4194304); } function inDecoratorContext() { - return inContext(4); + return inContext(16777216); } function inAwaitContext() { - return inContext(8); + return inContext(33554432); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -6259,11 +6497,11 @@ var ts; function finishNode(node, end) { node.end = end === undefined ? scanner.getStartPos() : end; if (contextFlags) { - node.parserContextFlags = contextFlags; + node.flags |= contextFlags; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16; + node.flags |= 67108864; } return node; } @@ -6325,7 +6563,7 @@ var ts; return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(137); + var node = createNode(138); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -6387,7 +6625,7 @@ var ts; case 2: return token === 71 || token === 77; case 4: - return isStartOfTypeMember(); + return lookAhead(isTypeMemberStart); case 5: return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); case 6: @@ -6577,7 +6815,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 31; + var nodeContextFlags = node.flags & 62914560; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -6624,14 +6862,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 145: - case 150: case 146: + case 151: case 147: - case 142: - case 194: + case 148: + case 143: + case 195: return true; - case 144: + case 145: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 69 && methodDeclaration.name.originalKeywordKind === 121; @@ -6643,8 +6881,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 244: case 245: + case 246: return true; } } @@ -6653,65 +6891,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 216: + case 217: + case 197: case 196: - case 195: + case 200: case 199: - case 198: - case 211: + case 212: + case 208: + case 210: case 207: - case 209: case 206: + case 204: case 205: case 203: - case 204: case 202: - case 201: - case 208: - case 197: - case 212: - case 210: - case 200: + case 209: + case 198: case 213: + case 211: + case 201: + case 214: + case 226: case 225: - case 224: + case 232: case 231: - case 230: - case 221: - case 217: + case 222: case 218: - case 220: case 219: + case 221: + case 220: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 250; + return node.kind === 251; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 149: - case 143: case 150: - case 141: - case 148: + case 144: + case 151: + case 142: + case 149: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 214) { + if (node.kind !== 215) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 139) { + if (node.kind !== 140) { return false; } var parameter = node; @@ -6756,7 +6994,7 @@ var ts; } } ; - function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimeter) { + function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; @@ -6774,7 +7012,7 @@ var ts; break; } parseExpected(24); - if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token === 23 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -6811,7 +7049,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(136, entity.pos); + var node = createNode(137, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6828,7 +7066,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(186); + var template = createNode(187); template.head = parseTemplateLiteralFragment(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -6841,7 +7079,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(193); + var span = createNode(194); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -6855,7 +7093,7 @@ var ts; return finishNode(span); } function parseStringLiteralTypeNode() { - return parseLiteralLikeNode(163, true); + return parseLiteralLikeNode(164, true); } function parseLiteralNode(internName) { return parseLiteralLikeNode(token, internName); @@ -6879,39 +7117,39 @@ var ts; if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 32768; + node.isOctalLiteral = true; } return node; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(152, typeName.pos); + var node = createNode(153, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } - function parseTypePredicate(lhs) { + function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(151, lhs.pos); + var node = createNode(152, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(162); + var node = createNode(163); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(155); + var node = createNode(156); parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(138); + var node = createNode(139); node.name = parseIdentifier(); if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { @@ -6944,7 +7182,7 @@ var ts; } } function parseParameter() { - var node = createNode(139); + var node = createNode(140); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -6955,7 +7193,7 @@ var ts; node.questionToken = parseOptionalToken(53); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseBindingElementInitializer(inParameter) { return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); @@ -6999,7 +7237,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 149) { + if (kind === 150) { parseExpected(92); } fillSignature(54, false, false, false, node); @@ -7039,7 +7277,7 @@ var ts; return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(150, fullStart); + var node = createNode(151, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -7047,12 +7285,12 @@ var ts; parseTypeMemberSemicolon(); return finishNode(node); } - function parsePropertyOrMethodSignature() { - var fullStart = scanner.getStartPos(); + function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(143, fullStart); + var method = createNode(144, fullStart); + setModifiers(method, modifiers); method.name = name; method.questionToken = questionToken; fillSignature(54, false, false, false, method); @@ -7060,7 +7298,8 @@ var ts; return finishNode(method); } else { - var property = createNode(141, fullStart); + var property = createNode(142, fullStart); + setModifiers(property, modifiers); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7071,78 +7310,51 @@ var ts; return finishNode(property); } } - function isStartOfTypeMember() { - switch (token) { - case 17: - case 25: - case 19: - return true; - default: - if (ts.isModifierKind(token)) { - var result = lookAhead(isStartOfIndexSignatureDeclaration); - if (result) { - return result; - } - } - return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); + function isTypeMemberStart() { + var idToken; + if (token === 17 || token === 25) { + return true; } - } - function isStartOfIndexSignatureDeclaration() { while (ts.isModifierKind(token)) { + idToken = token; nextToken(); } - return isIndexSignature(); - } - function isTypeMemberWithLiteralPropertyName() { - nextToken(); - return token === 17 || - token === 25 || - token === 53 || - token === 54 || - canParseSemicolon(); + if (token === 19) { + return true; + } + if (isLiteralPropertyName()) { + idToken = token; + nextToken(); + } + if (idToken) { + return token === 17 || + token === 25 || + token === 53 || + token === 54 || + canParseSemicolon(); + } + return false; } function parseTypeMember() { - switch (token) { - case 17: - case 25: - return parseSignatureMember(148); - case 19: - return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) - : parsePropertyOrMethodSignature(); - case 92: - if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(149); - } - case 9: - case 8: - return parsePropertyOrMethodSignature(); - default: - if (ts.isModifierKind(token)) { - var result = tryParse(parseIndexSignatureWithModifiers); - if (result) { - return result; - } - } - if (ts.tokenIsIdentifierOrKeyword(token)) { - return parsePropertyOrMethodSignature(); - } + if (token === 17 || token === 25) { + return parseSignatureMember(149); } - } - function parseIndexSignatureWithModifiers() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); + if (token === 92 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(150); + } + var fullStart = getNodePos(); var modifiers = parseModifiers(); - return isIndexSignature() - ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) - : undefined; + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, undefined, modifiers); + } + return parsePropertyOrMethodSignature(fullStart, modifiers); } function isStartOfConstructSignature() { nextToken(); return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(156); + var node = createNode(157); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7158,12 +7370,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(158); + var node = createNode(159); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(161); + var node = createNode(162); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7171,7 +7383,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 154) { + if (kind === 155) { parseExpected(92); } fillSignature(34, false, false, false, node); @@ -7184,10 +7396,10 @@ var ts; function parseNonArrayType() { switch (token) { case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -7197,7 +7409,7 @@ var ts; case 97: { var thisKeyword = parseThisTypeNode(); if (token === 124 && !scanner.hasPrecedingLineBreak()) { - return parseTypePredicate(thisKeyword); + return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; @@ -7218,10 +7430,10 @@ var ts; function isStartOfType() { switch (token) { case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: case 103: case 97: case 101: @@ -7245,7 +7457,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(157, type.pos); + var node = createNode(158, type.pos); node.elementType = type; type = finishNode(node); } @@ -7267,10 +7479,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(160, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(161, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(159, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(160, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7278,16 +7490,29 @@ var ts; } return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); } + function skipParameterStart() { + if (ts.isModifierKind(token)) { + parseModifiers(); + } + if (isIdentifier()) { + nextToken(); + return true; + } + if (token === 19 || token === 15) { + var previousErrorCount = parseDiagnostics.length; + parseIdentifierOrPattern(); + return previousErrorCount === parseDiagnostics.length; + } + return false; + } function isUnambiguouslyStartOfFunctionType() { nextToken(); if (token === 18 || token === 22) { return true; } - if (isIdentifier() || ts.isModifierKind(token)) { - nextToken(); + if (skipParameterStart()) { if (token === 54 || token === 24 || - token === 53 || token === 56 || - isIdentifier() || ts.isModifierKind(token)) { + token === 53 || token === 56) { return true; } if (token === 18) { @@ -7303,7 +7528,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(151, typePredicateVariable.pos); + var node = createNode(152, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -7320,14 +7545,14 @@ var ts; } } function parseType() { - return doOutsideOfContext(10, parseTypeWorker); + return doOutsideOfContext(41943040, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(153); + return parseFunctionOrConstructorType(154); } if (token === 92) { - return parseFunctionOrConstructorType(154); + return parseFunctionOrConstructorType(155); } return parseUnionTypeOrHigher(); } @@ -7446,7 +7671,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(187); + var node = createNode(188); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7460,8 +7685,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(177, identifier.pos); - var parameter = createNode(139, identifier.pos); + var node = createNode(178, identifier.pos); + var parameter = createNode(140, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -7572,7 +7797,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(177); + var node = createNode(178); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 256); fillSignature(54, false, isAsync, !allowAmbiguity, node); @@ -7604,7 +7829,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(185, leftOperand.pos); + var node = createNode(186, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -7617,7 +7842,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 135; + return t === 90 || t === 136; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7695,43 +7920,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(184, left.pos); + var node = createNode(185, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(192, left.pos); + var node = createNode(193, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(182); + var node = createNode(183); node.operator = token; nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(178); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(179); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(180); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(181); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token === 119) { if (inAwaitContext()) { @@ -7742,7 +7967,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -7761,7 +7986,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token === 38) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 174) { + if (simpleUnaryExpression.kind === 175) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -7809,7 +8034,7 @@ var ts; } function parseIncrementExpression() { if (token === 41 || token === 42) { - var node = createNode(182); + var node = createNode(183); node.operator = token; nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -7821,7 +8046,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(183, expression.pos); + var node = createNode(184, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7844,7 +8069,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(169, expression.pos); + var node = createNode(170, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -7863,8 +8088,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 238) { - var node = createNode(236, opening.pos); + if (opening.kind === 239) { + var node = createNode(237, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -7874,14 +8099,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 237); + ts.Debug.assert(opening.kind === 238); result = opening; } if (inExpressionContext && token === 25) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(184, result.pos); + var badNode = createNode(185, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -7893,13 +8118,13 @@ var ts; return result; } function parseJsxText() { - var node = createNode(239, scanner.getStartPos()); + var node = createNode(240, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 239: + case 240: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -7935,7 +8160,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(238, fullStart); + node = createNode(239, fullStart); scanJsxText(); } else { @@ -7947,7 +8172,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(237, fullStart); + node = createNode(238, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7958,7 +8183,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(136, elementName.pos); + var node = createNode(137, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -7966,7 +8191,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(243); + var node = createNode(244); parseExpected(15); if (token !== 16) { node.expression = parseAssignmentExpressionOrHigher(); @@ -7985,7 +8210,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(241); + var node = createNode(242); node.name = parseIdentifierName(); if (parseOptional(56)) { switch (token) { @@ -8000,7 +8225,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(242); + var node = createNode(243); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -8008,7 +8233,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(240); + var node = createNode(241); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -8021,7 +8246,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(174); + var node = createNode(175); parseExpected(25); node.type = parseType(); parseExpected(27); @@ -8032,7 +8257,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(169, expression.pos); + var propertyAccess = createNode(170, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -8040,7 +8265,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(170, expression.pos); + var indexedAccess = createNode(171, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -8054,7 +8279,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(173, expression.pos); + var tagExpression = createNode(174, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -8073,7 +8298,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(171, expression.pos); + var callExpr = createNode(172, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -8081,7 +8306,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(171, expression.pos); + var callExpr = createNode(172, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -8176,42 +8401,43 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(175); + var node = createNode(176); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(188); + var node = createNode(189); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(190) : + token === 24 ? createNode(191) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(167); + var node = createNode(168); parseExpected(19); - if (scanner.hasPrecedingLineBreak()) - node.flags |= 1024; + if (scanner.hasPrecedingLineBreak()) { + node.multiLine = true; + } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); parseExpected(20); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(123)) { - return parseAccessorDeclaration(146, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(129)) { return parseAccessorDeclaration(147, fullStart, decorators, modifiers); } + else if (parseContextualModifier(130)) { + return parseAccessorDeclaration(148, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -8231,7 +8457,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(249, fullStart); + var shorthandDeclaration = createNode(250, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(56); @@ -8239,23 +8465,23 @@ var ts; shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } - return finishNode(shorthandDeclaration); + return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(248, fullStart); + var propertyAssignment = createNode(249, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(54); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); + return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(168); + var node = createNode(169); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 1024; + node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(16); @@ -8266,7 +8492,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(176); + var node = createNode(177); setModifiers(node, parseModifiers()); parseExpected(87); node.asteriskToken = parseOptionalToken(37); @@ -8282,13 +8508,13 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(true); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(172); + var node = createNode(173); parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -8298,7 +8524,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(195); + var node = createNode(196); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8326,12 +8552,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(197); + var node = createNode(198); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(199); + var node = createNode(200); parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8341,7 +8567,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(200); + var node = createNode(201); parseExpected(79); node.statement = parseStatement(); parseExpected(104); @@ -8352,7 +8578,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(201); + var node = createNode(202); parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8375,21 +8601,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(90)) { - var forInStatement = createNode(203, pos); + var forInStatement = createNode(204, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(135)) { - var forOfStatement = createNode(204, pos); + else if (parseOptional(136)) { + var forOfStatement = createNode(205, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(202, pos); + var forStatement = createNode(203, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8407,7 +8633,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 206 ? 70 : 75); + parseExpected(kind === 207 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8415,7 +8641,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(207); + var node = createNode(208); parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -8424,7 +8650,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8433,7 +8659,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(244); + var node = createNode(245); parseExpected(71); node.expression = allowInAnd(parseExpression); parseExpected(54); @@ -8441,7 +8667,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(245); + var node = createNode(246); parseExpected(77); parseExpected(54); node.statements = parseList(3, parseStatement); @@ -8451,12 +8677,12 @@ var ts; return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(223, scanner.getStartPos()); + var caseBlock = createNode(224, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8464,14 +8690,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(211); + var node = createNode(212); parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(212); + var node = createNode(213); parseExpected(100); node.tryBlock = parseBlock(false); node.catchClause = token === 72 ? parseCatchClause() : undefined; @@ -8482,7 +8708,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(247); + var result = createNode(248); parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); @@ -8492,7 +8718,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(213); + var node = createNode(214); parseExpected(76); parseSemicolon(); return finishNode(node); @@ -8501,16 +8727,16 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(210, fullStart); + var labeledStatement = createNode(211, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); + return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(198, fullStart); + var expressionStatement = createNode(199, fullStart); expressionStatement.expression = expression; parseSemicolon(); - return finishNode(expressionStatement); + return addJSDocComment(finishNode(expressionStatement)); } } function nextTokenIsIdentifierOrKeywordOnSameLine() { @@ -8536,7 +8762,7 @@ var ts; case 81: return true; case 107: - case 132: + case 133: return nextTokenIsIdentifierOnSameLine(); case 125: case 126: @@ -8547,12 +8773,13 @@ var ts; case 110: case 111: case 112: + case 127: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 134: + case 135: return nextToken() === 15; case 89: nextToken(); @@ -8610,13 +8837,14 @@ var ts; case 107: case 125: case 126: - case 132: - case 134: + case 133: + case 135: return true; case 112: case 110: case 111: case 113: + case 127: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8655,9 +8883,9 @@ var ts; case 86: return parseForOrForInOrForOfStatement(); case 75: - return parseBreakOrContinueStatement(205); - case 70: return parseBreakOrContinueStatement(206); + case 70: + return parseBreakOrContinueStatement(207); case 94: return parseReturnStatement(); case 105: @@ -8676,7 +8904,7 @@ var ts; return parseDeclaration(); case 118: case 107: - case 132: + case 133: case 125: case 126: case 122: @@ -8689,7 +8917,8 @@ var ts; case 112: case 115: case 113: - case 134: + case 127: + case 135: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8712,11 +8941,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 107: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 132: + case 133: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 81: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 134: + case 135: case 125: case 126: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -8729,7 +8958,7 @@ var ts; parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(234, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(235, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8750,16 +8979,16 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(190); + return createNode(191); } - var node = createNode(166); + var node = createNode(167); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(166); + var node = createNode(167); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 54) { @@ -8774,14 +9003,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(164); + var node = createNode(165); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(165); + var node = createNode(166); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -8800,7 +9029,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(214); + var node = createNode(215); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8809,21 +9038,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(215); + var node = createNode(216); switch (token) { case 102: break; case 108: - node.flags |= 8192; + node.flags |= 1024; break; case 74: - node.flags |= 16384; + node.flags |= 2048; break; default: ts.Debug.fail(); } nextToken(); - if (token === 135 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 136 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8838,15 +9067,15 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(196, fullStart); + var node = createNode(197, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(87); @@ -8856,19 +9085,19 @@ var ts; var isAsync = !!(node.flags & 256); fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(145, pos); + var node = createNode(146, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(121); fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(144, fullStart); + var method = createNode(145, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8878,18 +9107,18 @@ var ts; var isAsync = !!(method.flags & 256); fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); + return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(142, fullStart); + var property = createNode(143, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = modifiers && modifiers.flags & 64 + property.initializer = modifiers && modifiers.flags & 32 ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(2 | 1, parseNonParameterInitializer); + : doOutsideOfContext(8388608 | 4194304, parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } @@ -8922,6 +9151,7 @@ var ts; case 110: case 111: case 113: + case 127: return true; default: return false; @@ -8950,7 +9180,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { + if (!ts.isKeyword(idToken) || idToken === 130 || idToken === 123) { return true; } switch (token) { @@ -8977,7 +9207,7 @@ var ts; decorators = []; decorators.pos = decoratorStart; } - var decorator = createNode(140, decoratorStart); + var decorator = createNode(141, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -9033,7 +9263,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(194); + var result = createNode(195); nextToken(); return finishNode(result); } @@ -9064,10 +9294,10 @@ var ts; ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 189); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 190); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 217); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 218); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -9102,7 +9332,7 @@ var ts; } function parseHeritageClause() { if (token === 83 || token === 106) { - var node = createNode(246); + var node = createNode(247); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -9111,7 +9341,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(191); + var node = createNode(192); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -9125,7 +9355,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218, fullStart); + var node = createNode(219, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(107); @@ -9136,10 +9366,10 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(219, fullStart); + var node = createNode(220, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(132); + parseExpected(133); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(56); @@ -9148,13 +9378,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNode(250, scanner.getStartPos()); + var node = createNode(251, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(81); @@ -9169,7 +9399,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(222, scanner.getStartPos()); + var node = createNode(223, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -9180,24 +9410,24 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(221, fullStart); - var namespaceFlag = flags & 65536; + var node = createNode(222, fullStart); + var namespaceFlag = flags & 4096; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 2 | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221, fullStart); + var node = createNode(222, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (token === 134) { + if (token === 135) { node.name = parseIdentifier(); - node.flags |= 2097152; + node.flags |= 131072; } else { node.name = parseLiteralNode(true); @@ -9207,11 +9437,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (token === 134) { + if (token === 135) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(126)) { - flags |= 65536; + flags |= 4096; } else { parseExpected(125); @@ -9222,7 +9452,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 127 && + return token === 128 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -9237,8 +9467,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 && token !== 133) { - var importEqualsDeclaration = createNode(224, fullStart); + if (token !== 24 && token !== 134) { + var importEqualsDeclaration = createNode(225, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -9248,27 +9478,27 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(225, fullStart); + var importDeclaration = createNode(226, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 37 || token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(133); + parseExpected(134); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(226, fullStart); + var importClause = createNode(227, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(228); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(229); } return finishNode(importClause); } @@ -9278,8 +9508,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(235); - parseExpected(127); + var node = createNode(236); + parseExpected(128); parseExpected(17); node.expression = parseModuleSpecifier(); parseExpected(18); @@ -9296,7 +9526,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(227); + var namespaceImport = createNode(228); parseExpected(37); parseExpected(116); namespaceImport.name = parseIdentifier(); @@ -9304,14 +9534,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 228 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 229 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(233); + return parseImportOrExportSpecifier(234); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(229); + return parseImportOrExportSpecifier(230); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9330,23 +9560,23 @@ var ts; else { node.name = identifierName; } - if (kind === 229 && checkIdentifierIsKeyword) { + if (kind === 230 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { - parseExpected(133); + parseExpected(134); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(232); - if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(133); + node.exportClause = parseNamedImportsOrExports(233); + if (token === 134 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(134); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9354,7 +9584,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(56)) { @@ -9425,11 +9655,11 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 2 - || node.kind === 224 && node.moduleReference.kind === 235 - || node.kind === 225 - || node.kind === 230 + return node.flags & 1 + || node.kind === 225 && node.moduleReference.kind === 236 + || node.kind === 226 || node.kind === 231 + || node.kind === 232 ? node : undefined; }); @@ -9454,17 +9684,17 @@ var ts; } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, true, undefined); - var jsDocTypeExpression = parseJSDocTypeExpression(start, length); + initializeState("file.js", content, 2, undefined, 1); + scanner.setText(content, start, length); + token = scanner.scan(); + var jsDocTypeExpression = parseJSDocTypeExpression(); var diagnostics = parseDiagnostics; clearState(); return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - function parseJSDocTypeExpression(start, length) { - scanner.setText(sourceText, start, length); - token = nextToken(); - var result = createNode(252); + function parseJSDocTypeExpression() { + var result = createNode(253, scanner.getTokenPos()); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -9475,12 +9705,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 47) { - var unionType = createNode(256, type.pos); + var unionType = createNode(257, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 56) { - var optionalType = createNode(263, type.pos); + var optionalType = createNode(264, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9491,20 +9721,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(255, type.pos); + var arrayType = createNode(256, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } else if (token === 53) { - var nullableType = createNode(258, type.pos); + var nullableType = createNode(259, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 49) { - var nonNullableType = createNode(259, type.pos); + var nonNullableType = createNode(260, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9538,37 +9768,37 @@ var ts; case 97: return parseJSDocThisType(); case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: case 103: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(267); + var result = createNode(268); nextToken(); parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(266); + var result = createNode(267); nextToken(); parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(265); + var result = createNode(266); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(264); + var result = createNode(265); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); @@ -9581,20 +9811,28 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(139); + var parameter = createNode(140); parameter.type = parseJSDocType(); + if (parseOptional(56)) { + parameter.questionToken = createNode(56); + } return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(262); + var result = createNode(263); result.name = parseSimplePropertyName(); - while (parseOptional(21)) { - if (token === 25) { - result.typeArguments = parseTypeArguments(); - break; - } - else { - result.name = parseQualifiedName(result.name); + if (token === 25) { + result.typeArguments = parseTypeArguments(); + } + else { + while (parseOptional(21)) { + if (token === 25) { + result.typeArguments = parseTypeArguments(); + break; + } + else { + result.name = parseQualifiedName(result.name); + } } } return finishNode(result); @@ -9615,13 +9853,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(136, left.pos); + var result = createNode(137, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(260); + var result = createNode(261); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -9629,7 +9867,7 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(261); + var result = createNode(262); result.name = parseSimplePropertyName(); if (token === 54) { nextToken(); @@ -9638,13 +9876,13 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(257); + var result = createNode(258); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -9658,7 +9896,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(256); + var result = createNode(257); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -9676,7 +9914,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(253); + var result = createNode(254); nextToken(); return finishNode(result); } @@ -9689,29 +9927,35 @@ var ts; token === 27 || token === 56 || token === 47) { - var result = createNode(254, pos); + var result = createNode(255, pos); return finishNode(result); } else { - var result = createNode(258, pos); + var result = createNode(259, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, true, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); + initializeState("file.js", content, 2, undefined, 1); + sourceFile = { languageVariant: 0, text: content }; + var jsDocComment = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; } JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; function parseJSDocComment(parent, start, length) { + var saveToken = token; + var saveParseDiagnosticsLength = parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; var comment = parseJSDocCommentWorker(start, length); if (comment) { - fixupParentReferences(comment); comment.parent = parent; } + token = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; @@ -9724,60 +9968,64 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; - var pos; - if (length >= "/** */".length) { - if (content.charCodeAt(start) === 47 && - content.charCodeAt(start + 1) === 42 && - content.charCodeAt(start + 2) === 42 && - content.charCodeAt(start + 3) !== 42) { + var result; + if (content.charCodeAt(start) === 47 && + content.charCodeAt(start + 1) === 42 && + content.charCodeAt(start + 2) === 42 && + content.charCodeAt(start + 3) !== 42) { + scanner.scanRange(start + 3, length - 5, function () { var canParseTag = true; var seenAsterisk = true; - for (pos = start + "/**".length; pos < end;) { - var ch = content.charCodeAt(pos); - pos++; - if (ch === 64 && canParseTag) { - parseTag(); - canParseTag = false; - continue; - } - if (ts.isLineBreak(ch)) { - canParseTag = true; - seenAsterisk = false; - continue; - } - if (ts.isWhiteSpace(ch)) { - continue; - } - if (ch === 42) { - if (seenAsterisk) { + nextJSDocToken(); + while (token !== 1) { + switch (token) { + case 55: + if (canParseTag) { + parseTag(); + } + seenAsterisk = false; + break; + case 4: + canParseTag = true; + seenAsterisk = false; + break; + case 37: + if (seenAsterisk) { + canParseTag = false; + } + seenAsterisk = true; + break; + case 69: canParseTag = false; - } - seenAsterisk = true; - continue; + break; + case 1: + break; } - canParseTag = false; + nextJSDocToken(); } - } + result = createJSDocComment(); + }); } - return createJSDocComment(); + return result; function createJSDocComment() { if (!tags) { return undefined; } - var result = createNode(268, start); + var result = createNode(269, start); result.tags = tags; return finishNode(result, end); } function skipWhitespace() { - while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { - pos++; + while (token === 5 || token === 4) { + nextJSDocToken(); } } function parseTag() { - ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(55, pos - 1); - atToken.end = pos; - var tagName = scanIdentifier(); + ts.Debug.assert(token === 55); + var atToken = createNode(55, scanner.getTokenPos()); + atToken.end = scanner.getTextPos(); + nextJSDocToken(); + var tagName = parseJSDocIdentifier(); if (!tagName) { return; } @@ -9801,10 +10049,10 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(269, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; - return finishNode(result, pos); + return finishNode(result); } function addTag(tag) { if (tag) { @@ -9817,12 +10065,10 @@ var ts; } } function tryParseTypeExpression() { - skipWhitespace(); - if (content.charCodeAt(pos) !== 123) { + if (token !== 15) { return undefined; } - var typeExpression = parseJSDocTypeExpression(pos, end - pos); - pos = typeExpression.end; + var typeExpression = parseJSDocTypeExpression(); return typeExpression; } function handleParamTag(atToken, tagName) { @@ -9830,17 +10076,20 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (content.charCodeAt(pos) === 91) { - pos++; - skipWhitespace(); - name = scanIdentifier(); + if (parseOptionalToken(19)) { + name = parseJSDocIdentifier(); isBracketed = true; + if (parseOptionalToken(56)) { + parseExpression(); + } + parseExpected(20); } - else { - name = scanIdentifier(); + else if (token === 69) { + name = parseJSDocIdentifier(); } if (!name) { - parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); + parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + return undefined; } var preName, postName; if (typeExpression) { @@ -9852,84 +10101,81 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(270, atToken.pos); + var result = createNode(271, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; result.typeExpression = typeExpression; result.postParameterName = postName; result.isBracketed = isBracketed; - return finishNode(result, pos); + return finishNode(result); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 271; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(271, 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 === 272; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var result = createNode(272, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); + return finishNode(result); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 273; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var typeParameters = []; - typeParameters.pos = pos; - while (true) { - skipWhitespace(); - var startPos = pos; - var name_8 = scanIdentifier(); - if (!name_8) { - parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); - return undefined; - } - var typeParameter = createNode(138, name_8.pos); - typeParameter.name = name_8; - finishNode(typeParameter, pos); - typeParameters.push(typeParameter); - skipWhitespace(); - if (content.charCodeAt(pos) !== 44) { - break; - } - pos++; - } - typeParameters.end = pos; var result = createNode(273, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; - return finishNode(result, pos); + result.typeExpression = tryParseTypeExpression(); + return finishNode(result); } - function scanIdentifier() { - var startPos = pos; - for (; pos < end; pos++) { - var ch = content.charCodeAt(pos); - if (pos === startPos && ts.isIdentifierStart(ch, 2)) { - continue; - } - else if (pos > startPos && ts.isIdentifierPart(ch, 2)) { - continue; - } - break; + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 274; })) { + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - if (startPos === pos) { + var typeParameters = []; + typeParameters.pos = scanner.getStartPos(); + while (true) { + var name_8 = parseJSDocIdentifier(); + if (!name_8) { + parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + return undefined; + } + var typeParameter = createNode(139, name_8.pos); + typeParameter.name = name_8; + finishNode(typeParameter); + typeParameters.push(typeParameter); + if (token === 24) { + nextJSDocToken(); + } + else { + break; + } + } + var result = createNode(274, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeParameters = typeParameters; + finishNode(result); + typeParameters.end = result.end; + return result; + } + function nextJSDocToken() { + return token = scanner.scanJSDocToken(); + } + function parseJSDocIdentifier() { + if (token !== 69) { + parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(69, startPos); - result.text = content.substring(startPos, pos); - return finishNode(result, pos); + var pos = scanner.getTokenPos(); + var end = scanner.getTextPos(); + var result = createNode(69, pos); + result.text = content.substring(pos, end); + finishNode(result, end); + nextJSDocToken(); + return result; } } JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; @@ -9944,7 +10190,7 @@ var ts; return sourceFile; } if (sourceFile.statements.length === 0) { - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind); } var incrementalSourceFile = sourceFile; ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); @@ -9958,7 +10204,7 @@ var ts; ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -10228,16 +10474,16 @@ var ts; : 4; } function getModuleInstanceState(node) { - if (node.kind === 218 || node.kind === 219) { + if (node.kind === 219 || node.kind === 220) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 225 || node.kind === 224) && !(node.flags & 2)) { + else if ((node.kind === 226 || node.kind === 225) && !(node.flags & 1)) { return 0; } - else if (node.kind === 222) { + else if (node.kind === 223) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -10253,7 +10499,7 @@ var ts; }); return state; } - else if (node.kind === 221) { + else if (node.kind === 222) { return getModuleInstanceState(node.body); } else { @@ -10337,7 +10583,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 221)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 222)) { symbol.valueDeclaration = node; } } @@ -10347,7 +10593,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 137) { + if (node.name.kind === 138) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -10358,21 +10604,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 145: + case 146: return "__constructor"; - case 153: - case 148: - return "__call"; case 154: case 149: - return "__new"; + return "__call"; + case 155: case 150: + return "__new"; + case 151: return "__index"; - case 231: + case 232: return "__export"; - case 230: + case 231: return node.isExportEquals ? "export=" : "default"; - case 184: + case 185: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -10384,9 +10630,16 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 216: case 217: + case 218: return node.flags & 512 ? "default" : undefined; + case 265: + return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; + case 140: + ts.Debug.assert(node.parent.kind === 265); + var functionType = node.parent; + var index = ts.indexOf(functionType.parameters, node); + return "p" + index; } } function getDisplayName(node) { @@ -10431,9 +10684,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 2; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 233 || (node.kind === 224 && hasExportModifier)) { + if (node.kind === 234 || (node.kind === 225 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -10441,7 +10694,7 @@ var ts; } } else { - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 131072)) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 8192)) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -10479,12 +10732,12 @@ var ts; var savedHasExplicitReturn; var kind = node.kind; var flags = node.flags; - flags &= ~1572864; - flags &= ~62914560; - if (kind === 218) { + flags &= ~98304; + flags &= ~3932160; + if (kind === 219) { seenThisKeyword = false; } - var saveState = kind === 251 || kind === 222 || ts.isFunctionLikeKind(kind); + var saveState = kind === 252 || kind === 223 || ts.isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -10495,28 +10748,31 @@ var ts; hasExplicitReturn = false; labelStack = labelIndexMap = implicitLabels = undefined; } + if (ts.isInJavaScriptFile(node) && node.jsDocComment) { + bind(node.jsDocComment); + } bindReachableStatement(node); if (currentReachabilityState === 2 && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { - flags |= 524288; + flags |= 32768; if (hasExplicitReturn) { - flags |= 1048576; + flags |= 65536; } } - if (kind === 218) { - flags = seenThisKeyword ? flags | 262144 : flags & ~262144; + if (kind === 219) { + flags = seenThisKeyword ? flags | 16384 : flags & ~16384; } - if (kind === 251) { + if (kind === 252) { if (hasClassExtends) { - flags |= 4194304; + flags |= 262144; } if (hasDecorators) { - flags |= 8388608; + flags |= 524288; } if (hasParameterDecorators) { - flags |= 16777216; + flags |= 1048576; } if (hasAsyncFunctions) { - flags |= 33554432; + flags |= 2097152; } } node.flags = flags; @@ -10537,40 +10793,40 @@ var ts; return; } switch (node.kind) { - case 201: + case 202: bindWhileStatement(node); break; - case 200: + case 201: bindDoStatement(node); break; - case 202: + case 203: bindForStatement(node); break; - case 203: case 204: + case 205: bindForInOrForOfStatement(node); break; - case 199: + case 200: bindIfStatement(node); break; - case 207: - case 211: + case 208: + case 212: bindReturnOrThrow(node); break; + case 207: case 206: - case 205: bindBreakOrContinueStatement(node); break; - case 212: + case 213: bindTryStatement(node); break; - case 209: + case 210: bindSwitchStatement(node); break; - case 223: + case 224: bindCaseBlock(node); break; - case 210: + case 211: bindLabeledStatement(node); break; default: @@ -10632,14 +10888,14 @@ var ts; } function bindReturnOrThrow(n) { bind(n.expression); - if (n.kind === 207) { + if (n.kind === 208) { hasExplicitReturn = true; } currentReachabilityState = 4; } function bindBreakOrContinueStatement(n) { bind(n.label); - var isValidJump = jumpToLabel(n.label, n.kind === 206 ? currentReachabilityState : 4); + var isValidJump = jumpToLabel(n.label, n.kind === 207 ? currentReachabilityState : 4); if (isValidJump) { currentReachabilityState = 4; } @@ -10660,7 +10916,7 @@ var ts; var postSwitchLabel = pushImplicitLabel(); bind(n.expression); bind(n.caseBlock); - var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 245; }); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 246; }); var postSwitchState = hasDefault && currentReachabilityState !== 2 ? 4 : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); } @@ -10685,37 +10941,38 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 189: - case 217: + case 190: case 218: - case 220: - case 156: - case 168: + case 219: + case 221: + case 169: + case 157: + case 261: return 1; - case 148: case 149: case 150: - case 144: - case 143: - case 216: + case 151: case 145: + case 144: + case 217: case 146: case 147: - case 153: + case 148: case 154: - case 176: + case 155: case 177: - case 221: - case 251: - case 219: + case 178: + case 222: + case 252: + case 220: return 5; - case 247: - case 202: + case 248: case 203: case 204: - case 223: + case 205: + case 224: return 2; - case 195: + case 196: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -10731,38 +10988,40 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 221: + case 222: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 251: + case 252: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 189: - case 217: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 220: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 156: - case 168: + case 190: case 218: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 221: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 157: + case 169: + case 219: + case 261: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 153: case 154: - case 148: + case 155: case 149: case 150: - case 144: - case 143: + case 151: case 145: + case 144: case 146: case 147: - case 216: - case 176: + case 148: + case 217: case 177: - case 219: + case 178: + case 265: + case 220: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 64 + return node.flags & 32 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -10772,11 +11031,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 251 ? node : node.body; - if (body.kind === 251 || body.kind === 222) { + var body = node.kind === 252 ? node : node.body; + if (body.kind === 252 || body.kind === 223) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 231 || stat.kind === 230) { + if (stat.kind === 232 || stat.kind === 231) { return true; } } @@ -10785,16 +11044,16 @@ var ts; } function setExportContextFlag(node) { if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 131072; + node.flags |= 8192; } else { - node.flags &= ~131072; + node.flags &= ~8192; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (node.flags & 2) { + if (node.flags & 1) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } declareSymbolAndAddToSymbolTable(node, 512, 106639); @@ -10838,7 +11097,7 @@ var ts; continue; } var identifier = prop.name; - var currentKind = prop.kind === 248 || prop.kind === 249 || prop.kind === 144 + var currentKind = prop.kind === 249 || prop.kind === 250 || prop.kind === 145 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -10860,10 +11119,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 221: + case 222: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 251: + case 252: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -10942,7 +11201,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 32768) { + if (inStrictMode && node.isOctalLiteral) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -10985,17 +11244,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 251: - case 222: + case 252: + case 223: updateStrictModeStatementList(node.statements); return; - case 195: + case 196: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 217: - case 189: + case 218: + case 190: inStrictMode = true; return; } @@ -11020,7 +11279,7 @@ var ts; switch (node.kind) { case 69: return checkStrictModeIdentifier(node); - case 184: + case 185: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -11043,91 +11302,94 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 247: + case 248: return checkStrictModeCatchClause(node); - case 178: + case 179: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 183: + case 184: return checkStrictModePostfixUnaryExpression(node); - case 182: + case 183: return checkStrictModePrefixUnaryExpression(node); - case 208: + case 209: return checkStrictModeWithStatement(node); - case 162: + case 163: seenThisKeyword = true; return; - case 151: + case 152: return checkTypePredicate(node); - case 138: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); case 139: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 140: return bindParameter(node); - case 214: - case 166: + case 215: + case 167: return bindVariableDeclarationOrBindingElement(node); + case 143: case 142: - case 141: + case 262: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 248: case 249: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 250: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 251: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 148: case 149: case 150: + case 151: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 144: - case 143: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 216: - return bindFunctionDeclaration(node); case 145: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 144: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); + case 217: + return bindFunctionDeclaration(node); case 146: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 147: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 148: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 153: case 154: + case 155: + case 265: return bindFunctionOrConstructorType(node); - case 156: + case 157: + case 261: return bindAnonymousDeclaration(node, 2048, "__type"); - case 168: + case 169: return bindObjectLiteralExpression(node); - case 176: case 177: + case 178: return bindFunctionExpression(node); - case 171: + case 172: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 189: - case 217: - return bindClassLikeDeclaration(node); + case 190: case 218: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 219: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 220: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 221: + return bindEnumDeclaration(node); + case 222: return bindModuleDeclaration(node); - case 224: - case 227: - case 229: - case 233: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 226: - return bindImportClause(node); - case 231: - return bindExportDeclaration(node); + case 225: + case 228: case 230: + case 234: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 227: + return bindImportClause(node); + case 232: + return bindExportDeclaration(node); + case 231: return bindExportAssignment(node); - case 251: + case 252: return bindSourceFileIfExternalModule(); } } @@ -11136,7 +11398,7 @@ var ts; if (parameterName && parameterName.kind === 69) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 162) { + if (parameterName && parameterName.kind === 163) { seenThisKeyword = true; } bind(type); @@ -11151,11 +11413,11 @@ var ts; bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } function bindExportAssignment(node) { - var boundExpression = node.kind === 230 ? node.expression : node.right; + var boundExpression = node.kind === 231 ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (boundExpression.kind === 69) { + else if (boundExpression.kind === 69 && node.kind === 231) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -11190,24 +11452,29 @@ var ts; bindExportAssignment(node); } function bindThisPropertyAssignment(node) { - if (container.kind === 176 || container.kind === 216) { + if (container.kind === 177 || container.kind === 217) { container.symbol.members = container.symbol.members || {}; - declareSymbol(container.symbol.members, container.symbol, node, 4, 107455); + declareSymbol(container.symbol.members, container.symbol, node, 4, 107455 & ~4); } } function bindPrototypePropertyAssignment(node) { - var classId = node.left.expression.expression; - var funcSymbol = container.locals[classId.text]; + var leftSideOfAssignment = node.left; + var classPrototype = leftSideOfAssignment.expression; + var constructorFunction = classPrototype.expression; + leftSideOfAssignment.parent = node; + constructorFunction.parent = classPrototype; + classPrototype.parent = leftSideOfAssignment; + var funcSymbol = container.locals[constructorFunction.text]; if (!funcSymbol || !(funcSymbol.flags & 16)) { return; } if (!funcSymbol.members) { funcSymbol.members = {}; } - declareSymbol(funcSymbol.members, funcSymbol, node.left, 4, 107455); + declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 107455); } function bindCallExpression(node) { - if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) { setCommonJsModuleIndicator(node); } } @@ -11220,7 +11487,7 @@ var ts; hasDecorators = true; } } - if (node.kind === 217) { + if (node.kind === 218) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -11370,16 +11637,16 @@ var ts; function checkUnreachable(node) { switch (currentReachabilityState) { case 4: - var reportError = (ts.isStatement(node) && node.kind !== 197) || - node.kind === 217 || - (node.kind === 221 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 220 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatement(node) && node.kind !== 198) || + node.kind === 218 || + (node.kind === 222 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 221 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentReachabilityState = 8; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 196 || - ts.getCombinedNodeFlags(node.declarationList) & 24576 || + (node.kind !== 197 || + ts.getCombinedNodeFlags(node.declarationList) & 3072 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); @@ -11439,8 +11706,8 @@ var ts; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; - var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === 4; + var modulekind = ts.getEmitModuleKind(compilerOptions); + var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); undefinedSymbol.declarations = []; @@ -11506,14 +11773,16 @@ var ts; 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, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); + var enumNumberIndexInfo = createIndexInfo(stringType, true); var globals = {}; var globalESSymbolConstructorSymbol; var getGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; + var globalReadonlyArrayType; var globalStringType; var globalNumberType; var globalBooleanType; @@ -11524,6 +11793,7 @@ var ts; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; + var anyReadonlyArrayType; var getGlobalClassDecoratorType; var getGlobalParameterDecoratorType; var getGlobalPropertyDecoratorType; @@ -11673,7 +11943,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 221 && source.valueDeclaration.kind !== 221))) { + (target.valueDeclaration.kind === 222 && source.valueDeclaration.kind !== 222))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -11741,8 +12011,14 @@ var ts; if (!mainModule) { return; } - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); - mergeSymbol(mainModule, moduleAugmentation.symbol); + mainModule = resolveExternalModuleSymbol(mainModule); + if (mainModule.flags & 1536) { + mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mergeSymbol(mainModule, moduleAugmentation.symbol); + } + else { + error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text); + } } } function addToSymbolTable(target, source, message) { @@ -11771,7 +12047,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function isGlobalSourceFile(node) { - return node.kind === 251 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 252 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -11789,9 +12065,9 @@ var ts; } } function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { - var constructoDeclaration = parameter.parent; + var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructoDeclaration.locals, parameterName, 107455); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 107455); var propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, 107455); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; @@ -11809,18 +12085,18 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 214 || + return declaration.kind !== 215 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 196 || - declaration.parent.parent.kind === 202) { + if (declaration.parent.parent.kind === 197 || + declaration.parent.parent.kind === 203) { return isSameScopeDescendentOf(usage, declaration, container); } - else if (declaration.parent.parent.kind === 204 || - declaration.parent.parent.kind === 203) { + else if (declaration.parent.parent.kind === 205 || + declaration.parent.parent.kind === 204) { var expression = declaration.parent.parent.expression; return isSameScopeDescendentOf(usage, expression, container); } @@ -11836,8 +12112,8 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 142 && - (current.parent.flags & 64) === 0 && + current.parent.kind === 143 && + (current.parent.flags & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -11858,18 +12134,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793056) { + if (meaning & result.flags & 793056 && lastLocation.kind !== 269) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 139 || - lastLocation.kind === 138 + lastLocation.kind === 140 || + lastLocation.kind === 139 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 139 || + lastLocation.kind === 140 || (lastLocation === location.type && - result.valueDeclaration.kind === 139); + result.valueDeclaration.kind === 140); } } if (useResult) { @@ -11881,12 +12157,12 @@ var ts; } } switch (location.kind) { - case 251: + case 252: if (!ts.isExternalOrCommonJsModule(location)) break; - case 221: + case 222: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 251 || ts.isAmbientModule(location)) { + if (location.kind === 252 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -11896,7 +12172,7 @@ var ts; } if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 233)) { + ts.getDeclarationOfKind(moduleExports[name], 234)) { break; } } @@ -11904,14 +12180,14 @@ var ts; break loop; } break; - case 220: + case 221: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 143: case 142: - case 141: - if (ts.isClassLike(location.parent) && !(location.flags & 64)) { + if (ts.isClassLike(location.parent) && !(location.flags & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -11920,17 +12196,17 @@ var ts; } } break; - case 217: - case 189: case 218: + case 190: + case 219: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { - if (lastLocation && lastLocation.flags & 64) { + if (lastLocation && lastLocation.flags & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } break loop; } - if (location.kind === 189 && meaning & 32) { + if (location.kind === 190 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -11938,28 +12214,28 @@ var ts; } } break; - case 137: + case 138: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 218) { + if (ts.isClassLike(grandparent) || grandparent.kind === 219) { 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 144: - case 143: case 145: + case 144: case 146: case 147: - case 216: - case 177: + case 148: + case 217: + case 178: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 176: + case 177: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -11972,8 +12248,8 @@ var ts; } } break; - case 140: - if (location.parent && location.parent.kind === 139) { + case 141: + if (location.parent && location.parent.kind === 140) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -12027,7 +12303,7 @@ var ts; error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg), symbolToString(classSymbol)); return true; } - if (location === container && !(location.flags & 64)) { + if (location === container && !(location.flags & 32)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); @@ -12043,7 +12319,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 214), errorLocation)) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 215), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -12060,10 +12336,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 224) { + if (node.kind === 225) { return node; } - while (node && node.kind !== 225) { + while (node && node.kind !== 226) { node = node.parent; } return node; @@ -12073,7 +12349,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 235) { + if (node.moduleReference.kind === 236) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -12086,7 +12362,7 @@ var ts; error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { - return resolveSymbol(moduleSymbol.exports["export="]) || resolveSymbol(moduleSymbol); + return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } return exportDefaultSymbol; } @@ -12157,17 +12433,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 224: + case 225: return getTargetOfImportEqualsDeclaration(node); - case 226: - return getTargetOfImportClause(node); case 227: + return getTargetOfImportClause(node); + case 228: return getTargetOfNamespaceImport(node); - case 229: - return getTargetOfImportSpecifier(node); - case 233: - return getTargetOfExportSpecifier(node); case 230: + return getTargetOfImportSpecifier(node); + case 234: + return getTargetOfExportSpecifier(node); + case 231: return getTargetOfExportAssignment(node); } } @@ -12209,10 +12485,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 230) { + if (node.kind === 231) { checkExpressionCached(node.expression); } - else if (node.kind === 233) { + else if (node.kind === 234) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -12222,17 +12498,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 224); + importDeclaration = ts.getAncestor(entityName, 225); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 136) { + if (entityName.kind === 69 || entityName.parent.kind === 137) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 224); + ts.Debug.assert(entityName.parent.kind === 225); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -12251,9 +12527,9 @@ var ts; return undefined; } } - else if (name.kind === 136 || name.kind === 169) { - var left = name.kind === 136 ? name.left : name.expression; - var right = name.kind === 136 ? name.right : name.name; + else if (name.kind === 137 || name.kind === 170) { + var left = name.kind === 137 ? name.left : name.expression; + var right = name.kind === 137 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -12308,7 +12584,7 @@ var ts; return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; } function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); @@ -12318,8 +12594,8 @@ var ts; } return symbol; } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="]; + function hasExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="] !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -12416,7 +12692,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 145 && ts.nodeIsPresent(member.body)) { + if (member.kind === 146 && ts.nodeIsPresent(member.body)) { return member; } } @@ -12459,19 +12735,19 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; + if (stringIndexInfo) + type.stringIndexInfo = stringIndexInfo; + if (numberIndexInfo) + type.numberIndexInfo = numberIndexInfo; return type; } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -12482,17 +12758,17 @@ var ts; } } switch (location_1.kind) { - case 251: + case 252: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 221: + case 222: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 217: case 218: + case 219: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -12525,7 +12801,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 234)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -12554,7 +12830,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 234)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -12609,7 +12885,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 251 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 252 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -12621,7 +12897,7 @@ var ts; if (!isDeclarationVisible(declaration)) { var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 2) && + !(anyImportSyntax.flags & 1) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -12641,11 +12917,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 155) { + if (entityName.parent.kind === 156) { meaning = 107455 | 1048576; } - else if (entityName.kind === 136 || entityName.kind === 169 || - entityName.parent.kind === 224) { + else if (entityName.kind === 137 || entityName.kind === 170 || + entityName.parent.kind === 225) { meaning = 1536; } else { @@ -12693,13 +12969,29 @@ var ts; } return result; } + function typePredicateToString(typePredicate, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function visibilityToString(flags) { + if (flags === 8) { + return "private"; + } + if (flags === 16) { + return "protected"; + } + return "public"; + } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 161) { + while (node.kind === 162) { node = node.parent; } - if (node.kind === 219) { + if (node.kind === 220) { return getSymbolOfNode(node); } } @@ -12707,7 +12999,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 222 && + node.parent.kind === 223 && ts.isExternalModuleAugmentation(node.parent.parent); } function getSymbolDisplayBuilder() { @@ -12718,10 +13010,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 189: + case 190: return "(Anonymous class)"; - case 176: case 177: + case 178: return "(Anonymous function)"; } } @@ -12786,15 +13078,9 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { if (type.flags & 16777343) { - if (type.flags & 134217728) { - buildTypePredicateDisplay(writer, type.predicate); - buildTypeDisplay(type.predicate.type, writer, enclosingDeclaration, flags, symbolStack); - } - else { - writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) - ? "any" - : type.intrinsicName); - } + writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) + ? "any" + : type.intrinsicName); } else if (type.flags & 33554432) { if (inObjectTypeLiteral) { @@ -12871,12 +13157,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_4 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_4); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_4, typeArguments, start, i, flags); writePunctuation(writer, 21); } } @@ -12931,11 +13217,11 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 32; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 251 || declaration.parent.kind === 222; + return declaration.parent.kind === 252 || declaration.parent.kind === 223; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -12948,17 +13234,38 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); - if (!declaration) { - return fallbackName; + function writeIndexSignature(info, keyword) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 127); + writeSpace(writer); + } + writePunctuation(writer, 19); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 54); + writeSpace(writer); + writeKeyword(writer, keyword); + writePunctuation(writer, 20); + writePunctuation(writer, 54); + writeSpace(writer); + writeType(info.type, 0); + writePunctuation(writer, 23); + writer.writeLine(); + } + } + function writePropertyWithModifiers(prop) { + if (isReadonlySymbol(prop)) { + writeKeyword(writer, 127); + writeSpace(writer); + } + buildSymbolDisplay(prop, writer); + if (prop.flags & 536870912) { + writePunctuation(writer, 53); } - ts.Debug.assert(declaration.parameters.length !== 0); - return ts.declarationNameToString(declaration.parameters[0].name); } function writeLiteralType(type, flags) { var resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 15); writePunctuation(writer, 16); @@ -13004,32 +13311,8 @@ var ts; writePunctuation(writer, 23); writer.writeLine(); } - if (resolved.stringIndexType) { - writePunctuation(writer, 19); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 54); - writeSpace(writer); - writeKeyword(writer, 130); - writePunctuation(writer, 20); - writePunctuation(writer, 54); - writeSpace(writer); - writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } - if (resolved.numberIndexType) { - writePunctuation(writer, 19); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 54); - writeSpace(writer); - writeKeyword(writer, 128); - writePunctuation(writer, 20); - writePunctuation(writer, 54); - writeSpace(writer); - writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } + writeIndexSignature(resolved.stringIndexInfo, 131); + writeIndexSignature(resolved.numberIndexInfo, 129); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -13037,20 +13320,14 @@ var ts; var signatures = getSignaturesOfType(t, 0); for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { var signature = signatures_1[_f]; - buildSymbolDisplay(p, writer); - if (p.flags & 536870912) { - writePunctuation(writer, 53); - } + writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); writePunctuation(writer, 23); writer.writeLine(); } } else { - buildSymbolDisplay(p, writer); - if (p.flags & 536870912) { - writePunctuation(writer, 53); - } + writePropertyWithModifiers(p); writePunctuation(writer, 54); writeSpace(writer); writeType(t, 0); @@ -13063,10 +13340,10 @@ var ts; inObjectTypeLiteral = saveInObjectTypeLiteral; } } - function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { + function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaration, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -13129,7 +13406,7 @@ var ts; } writePunctuation(writer, 18); } - function buildTypePredicateDisplay(writer, predicate) { + function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } @@ -13139,6 +13416,7 @@ var ts; writeSpace(writer); writeKeyword(writer, 124); writeSpace(writer); + buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { @@ -13149,8 +13427,13 @@ var ts; writePunctuation(writer, 54); } writeSpace(writer); - var returnType = getReturnTypeOfSignature(signature); - buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + if (signature.typePredicate) { + buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); + } + else { + var returnType = getReturnTypeOfSignature(signature); + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { @@ -13170,6 +13453,7 @@ var ts; buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, + buildTypePredicateDisplay: buildTypePredicateDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, @@ -13189,63 +13473,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 166: + case 167: return isDeclarationVisible(node.parent.parent); - case 214: + case 215: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 221: - case 217: + case 222: case 218: case 219: - case 216: case 220: - case 224: + case 217: + case 221: + case 225: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_4 = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 2) && - !(node.kind !== 224 && parent_4.kind !== 251 && ts.isInAmbientContext(parent_4))) { - return isGlobalSourceFile(parent_4); + var parent_5 = getDeclarationContainer(node); + if (!(ts.getCombinedNodeFlags(node) & 1) && + !(node.kind !== 225 && parent_5.kind !== 252 && ts.isInAmbientContext(parent_5))) { + return isGlobalSourceFile(parent_5); } - return isDeclarationVisible(parent_4); - case 142: - case 141: - case 146: - case 147: - case 144: + return isDeclarationVisible(parent_5); case 143: - if (node.flags & (16 | 32)) { + case 142: + case 147: + case 148: + case 145: + case 144: + if (node.flags & (8 | 16)) { return false; } - case 145: - case 149: - case 148: + case 146: case 150: - case 139: - case 222: - case 153: + case 149: + case 151: + case 140: + case 223: case 154: - case 156: - case 152: + case 155: case 157: + case 153: case 158: case 159: case 160: case 161: + case 162: return isDeclarationVisible(node.parent); - case 226: case 227: - case 229: - return false; - case 138: - case 251: - return true; + case 228: case 230: return false; + case 139: + case 252: + return true; + case 231: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -13253,10 +13537,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 230) { + if (node.parent && node.parent.kind === 231) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 233) { + else if (node.parent.kind === 234) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -13333,10 +13617,23 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 214 ? node.parent.parent.parent : node.parent; + while (node) { + switch (node.kind) { + case 215: + case 216: + case 230: + case 229: + case 228: + case 227: + node = node.parent; + break; + default: + return node.parent; + } + } } function getTypeOfPrototypeProperty(prototype) { - var classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); + var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } function getTypeOfPropertyOfType(type, name) { @@ -13357,7 +13654,7 @@ var ts; case 9: case 8: return name.text; - case 137: + case 138: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -13365,7 +13662,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 137 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 138 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -13380,7 +13677,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 164) { + if (pattern.kind === 165) { var name_10 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_10)) { return anyType; @@ -13417,11 +13714,44 @@ var ts; } return type; } + function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + var jsDocType = getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (jsDocType) { + return getTypeFromTypeNode(jsDocType); + } + } + function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + var typeTag = ts.getJSDocTypeTag(declaration); + if (typeTag && typeTag.typeExpression) { + return typeTag.typeExpression.type; + } + if (declaration.kind === 215 && + declaration.parent.kind === 216 && + declaration.parent.parent.kind === 197) { + var annotation = ts.getJSDocTypeTag(declaration.parent.parent); + if (annotation && annotation.typeExpression) { + return annotation.typeExpression.type; + } + } + else if (declaration.kind === 140) { + var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type; + } + } + return undefined; + } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 203) { - return stringType; + if (declaration.flags & 134217728) { + var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (type && type !== unknownType) { + return type; + } } if (declaration.parent.parent.kind === 204) { + return stringType; + } + if (declaration.parent.parent.kind === 205) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -13430,10 +13760,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 139) { + if (declaration.kind === 140) { var func = declaration.parent; - if (func.kind === 147 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 146); + if (func.kind === 148 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 147); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -13446,7 +13776,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 249) { + if (declaration.kind === 250) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -13493,7 +13823,7 @@ var ts; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - var elementTypes = ts.map(elements, function (e) { return e.kind === 190 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 191 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -13502,7 +13832,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 164 + return pattern.kind === 165 ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -13512,10 +13842,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 248) { - return type; - } - if (type.flags & 134217728 && (declaration.kind === 142 || declaration.kind === 141)) { + if (declaration.kind === 249) { return type; } return getWidenedType(type); @@ -13523,7 +13850,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 139 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 140 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -13536,17 +13863,17 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 247) { + if (declaration.parent.kind === 248) { return links.type = anyType; } - if (declaration.kind === 230) { + if (declaration.kind === 231) { return links.type = checkExpression(declaration.expression); } - if (declaration.kind === 184) { - return links.type = checkExpression(declaration.right); + if (declaration.kind === 185) { + return links.type = getUnionType(ts.map(symbol.declarations, function (decl) { return checkExpressionCached(decl.right); })); } - if (declaration.kind === 169) { - if (declaration.parent.kind === 184) { + if (declaration.kind === 170) { + if (declaration.parent.kind === 185) { return links.type = checkExpressionCached(declaration.parent.right); } } @@ -13572,7 +13899,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 146) { + if (accessor.kind === 147) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -13588,8 +13915,8 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 146); - var setter = ts.getDeclarationOfKind(symbol, 147); + var getter = ts.getDeclarationOfKind(symbol, 147); + var setter = ts.getDeclarationOfKind(symbol, 148); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -13615,7 +13942,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 146); + var getter_1 = ts.getDeclarationOfKind(symbol, 147); 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)); } } @@ -13704,9 +14031,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 217 || node.kind === 189 || - node.kind === 216 || node.kind === 176 || - node.kind === 144 || node.kind === 177) { + if (node.kind === 218 || node.kind === 190 || + node.kind === 217 || node.kind === 177 || + node.kind === 145 || node.kind === 178) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -13715,15 +14042,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 218); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 219); 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 === 218 || node.kind === 217 || - node.kind === 189 || node.kind === 219) { + if (node.kind === 219 || node.kind === 218 || + node.kind === 190 || node.kind === 220) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -13846,7 +14173,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 218 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 219 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -13875,8 +14202,8 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 218) { - if (declaration.flags & 262144) { + if (declaration.kind === 219) { + if (declaration.flags & 16384) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -13924,7 +14251,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 219); + var declaration = ts.getDeclarationOfKind(symbol, 220); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -13955,7 +14282,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 138).constraint) { + if (!ts.getDeclarationOfKind(symbol, 139).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -14002,16 +14329,16 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: case 103: - case 163: + case 164: return true; - case 157: + case 158: return isIndependentType(node.elementType); - case 152: + case 153: return isIndependentTypeReference(node); } return false; @@ -14020,7 +14347,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 145 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 146 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -14036,12 +14363,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 142: - case 141: - return isIndependentVariableLikeDeclaration(declaration); - case 144: case 143: + case 142: + return isIndependentVariableLikeDeclaration(declaration); case 145: + case 144: + case 146: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -14078,8 +14405,8 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0); + type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1); } return type; } @@ -14094,15 +14421,15 @@ var ts; var members = source.symbol.members; var callSignatures = source.declaredCallSignatures; var constructSignatures = source.declaredConstructSignatures; - var stringIndexType = source.declaredStringIndexType; - var numberIndexType = source.declaredNumberIndexType; + var stringIndexInfo = source.declaredStringIndexInfo; + var numberIndexInfo = source.declaredNumberIndexInfo; if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); - stringIndexType = instantiateType(source.declaredStringIndexType, mapper); - numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); + numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); } var baseTypes = getBaseTypes(source); if (baseTypes.length) { @@ -14116,11 +14443,11 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); + stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); + numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); @@ -14132,25 +14459,26 @@ var ts; type.typeArguments : ts.concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); @@ -14182,7 +14510,7 @@ var ts; var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { @@ -14238,41 +14566,46 @@ var ts; } return result || emptyArray; } - function getUnionIndexType(types, kind) { + function getUnionIndexInfo(types, kind) { var indexTypes = []; + var isAnyReadonly = false; for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { var type = types_1[_i]; - var indexType = getIndexTypeOfType(type, kind); - if (!indexType) { + var indexInfo = getIndexInfoOfType(type, kind); + if (!indexInfo) { return undefined; } - indexTypes.push(indexType); + indexTypes.push(indexInfo.type); + isAnyReadonly = isAnyReadonly || indexInfo.isReadonly; } - return getUnionType(indexTypes); + return createIndexInfo(getUnionType(indexTypes), isAnyReadonly); } function resolveUnionTypeMembers(type) { var callSignatures = getUnionSignatures(type.types, 0); var constructSignatures = getUnionSignatures(type.types, 1); - var stringIndexType = getUnionIndexType(type.types, 0); - var numberIndexType = getUnionIndexType(type.types, 1); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = getUnionIndexInfo(type.types, 0); + var numberIndexInfo = getUnionIndexInfo(type.types, 1); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } + function intersectIndexInfos(info1, info2) { + return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexType = undefined; - var numberIndexType = undefined; + var stringIndexInfo = undefined; + var numberIndexInfo = undefined; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); - stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0)); - numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1)); + stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); + numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; @@ -14280,17 +14613,17 @@ var ts; var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); var callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); var constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); - var stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); - var numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper); + var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048) { var members = symbol.members; var callSignatures = getSignaturesOfSymbol(members["__call"]); var constructSignatures = getSignaturesOfSymbol(members["__new"]); - var stringIndexType = getIndexTypeOfSymbol(symbol, 0); - var numberIndexType = getIndexTypeOfSymbol(symbol, 1); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); + var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { var members = emptySymbols; @@ -14310,8 +14643,8 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } - var numberIndexType = (symbol.flags & 384) ? stringType : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexType); + var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; + setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } @@ -14411,7 +14744,7 @@ var ts; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 | 32))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (8 | 16))) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -14493,15 +14826,44 @@ var ts; function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } - function getIndexTypeOfStructuredType(type, kind) { + function getIndexInfoOfStructuredType(type, kind) { if (type.flags & 130048) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; + return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo; } } + function getIndexTypeOfStructuredType(type, kind) { + var info = getIndexInfoOfStructuredType(type, kind); + return info && info.type; + } + function getIndexInfoOfType(type, kind) { + return getIndexInfoOfStructuredType(getApparentType(type), kind); + } function getIndexTypeOfType(type, kind) { return getIndexTypeOfStructuredType(getApparentType(type), kind); } + function getImplicitIndexTypeOfType(type, kind) { + if (isObjectLiteralType(type)) { + var propTypes = []; + for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + if (kind === 0 || isNumericLiteralName(prop.name)) { + propTypes.push(getTypeOfSymbol(prop)); + } + } + return getUnionType(propTypes); + } + return undefined; + } + function getTypeParametersFromJSDocTemplate(declaration) { + if (declaration.flags & 134217728) { + var templateTag = ts.getJSDocTemplateTag(declaration); + if (templateTag) { + return getTypeParametersFromDeclaration(templateTag.typeParameters); + } + } + return undefined; + } function getTypeParametersFromDeclaration(typeParameterDeclarations) { var result = []; ts.forEach(typeParameterDeclarations, function (node) { @@ -14522,6 +14884,20 @@ var ts; return result; } function isOptionalParameter(node) { + if (node.flags & 134217728) { + if (node.type && node.type.kind === 264) { + return true; + } + var paramTag = ts.getCorrespondingJSDocParameterTag(node); + if (paramTag) { + if (paramTag.isBracketed) { + return true; + } + if (paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 264; + } + } + } if (ts.hasQuestionToken(node)) { return true; } @@ -14554,15 +14930,19 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 145 ? + var classType = declaration.kind === 146 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : - declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; + declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : + getTypeParametersFromJSDocTemplate(declaration); var parameters = []; var hasStringLiterals = false; var minArgumentCount = -1; - for (var i = 0, n = declaration.parameters.length; i < n; i++) { + var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var returnType = undefined; + var typePredicate = undefined; + for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -14570,7 +14950,7 @@ var ts; paramSymbol = resolvedSymbol; } parameters.push(paramSymbol); - if (param.type && param.type.kind === 163) { + if (param.type && param.type.kind === 164) { hasStringLiterals = true; } if (param.initializer || param.questionToken || param.dotDotDotToken) { @@ -14585,23 +14965,35 @@ var ts; if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; } - var returnType; - if (classType) { + if (isJSConstructSignature) { + minArgumentCount--; + returnType = getTypeFromTypeNode(declaration.parameters[0].type); + } + else if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 152) { + typePredicate = createTypePredicateFromTypePredicateNode(declaration.type); + } } else { - if (declaration.kind === 146 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 147); + if (declaration.flags & 134217728) { + var type = getReturnTypeFromJSDocComment(declaration); + if (type && type !== unknownType) { + returnType = type; + } + } + if (declaration.kind === 147 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 148); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -14612,19 +15004,20 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 153: case 154: - case 216: - case 144: - case 143: + case 155: + case 217: case 145: - case 148: + case 144: + case 146: case 149: case 150: - case 146: + case 151: case 147: - case 176: + case 148: case 177: + case 178: + case 265: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -14704,7 +15097,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 145 || signature.declaration.kind === 149; + var isConstructor = signature.declaration.kind === 146 || signature.declaration.kind === 150; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -14718,7 +15111,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 128 : 130; + var syntaxKind = kind === 1 ? 129 : 131; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -14734,18 +15127,22 @@ var ts; } return undefined; } - function getIndexTypeOfSymbol(symbol, kind) { + function createIndexInfo(type, isReadonly, declaration) { + return { type: type, isReadonly: isReadonly, declaration: declaration }; + } + function getIndexInfoOfSymbol(symbol, kind) { var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType - : undefined; + if (declaration) { + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, (declaration.flags & 64) !== 0, declaration); + } + return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 138).constraint; + return ts.getDeclarationOfKind(type.symbol, 139).constraint; } function hasConstraintReferenceTo(type, target) { var checked; - while (type && type.flags & 512 && !ts.contains(checked, type)) { + while (type && !(type.flags & 33554432) && type.flags & 512 && !ts.contains(checked, type)) { if (type === target) { return true; } @@ -14774,7 +15171,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 138).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 139).parent); } function getTypeListId(types) { if (types) { @@ -14857,17 +15254,62 @@ var ts; } return getDeclaredTypeOfSymbol(symbol); } + function getTypeReferenceName(node) { + switch (node.kind) { + case 153: + return node.typeName; + case 263: + return node.name; + case 192: + if (ts.isSupportedExpressionWithTypeArguments(node)) { + return node.expression; + } + } + return undefined; + } + function resolveTypeReferenceName(node, typeReferenceName) { + if (!typeReferenceName) { + return unknownSymbol; + } + return resolveEntityName(typeReferenceName, 793056) || unknownSymbol; + } + function getTypeReferenceType(node, symbol) { + if (symbol === unknownSymbol) { + return unknownType; + } + if (symbol.flags & (32 | 64)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288) { + return getTypeFromTypeAliasReference(node, symbol); + } + if (symbol.flags & 107455 && node.kind === 263) { + return getTypeOfSymbol(symbol); + } + return getTypeFromNonGenericTypeReference(node, symbol); + } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 152 ? node.typeName : - ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : - undefined; - var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; - var type = symbol === unknownSymbol ? unknownType : - symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + var symbol; + var type; + if (node.kind === 263) { + var typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(node, typeReferenceName); + type = getTypeReferenceType(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + else { + var typeNameOrExpression = node.kind === 153 ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; + type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + } links.resolvedSymbol = symbol; links.resolvedType = type; } @@ -14886,9 +15328,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 217: case 218: - case 220: + case 219: + case 221: return declaration; } } @@ -15101,12 +15543,28 @@ var ts; } return links.resolvedType; } + function getTypeFromJSDocVariadicType(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var type = getTypeFromTypeNode(node.type); + links.resolvedType = type ? createArrayType(type) : unknownType; + } + return links.resolvedType; + } + function getTypeFromJSDocTupleType(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var types = ts.map(node.types, getTypeFromTypeNode); + links.resolvedType = createTupleType(types); + } + return links.resolvedType; + } function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 218)) { - if (!(container.flags & 64) && - (container.kind !== 145 || ts.isNodeDescendentOf(node, container.body))) { + if (parent && (ts.isClassLike(parent) || parent.kind === 219)) { + if (!(container.flags & 32) && + (container.kind !== 146 || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -15120,66 +15578,66 @@ var ts; } return links.resolvedType; } - function getPredicateType(node) { - return createPredicateType(getSymbolOfNode(node), createTypePredicateFromTypePredicateNode(node)); - } - function createPredicateType(symbol, predicate) { - var type = createType(8 | 134217728); - type.symbol = symbol; - type.predicate = predicate; - return type; - } - function getTypeFromPredicateTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getPredicateType(node); - } - return links.resolvedType; - } function getTypeFromTypeNode(node) { switch (node.kind) { case 117: + case 254: + case 255: return anyType; - case 130: + case 131: return stringType; - case 128: + case 129: return numberType; case 120: return booleanType; - case 131: + case 132: return esSymbolType; case 103: return voidType; - case 162: - return getTypeFromThisTypeNode(node); case 163: + return getTypeFromThisTypeNode(node); + case 164: return getTypeFromStringLiteralTypeNode(node); - case 152: - return getTypeFromTypeReference(node); - case 151: - return getTypeFromPredicateTypeNode(node); - case 191: - return getTypeFromTypeReference(node); - case 155: - return getTypeFromTypeQueryNode(node); - case 157: - return getTypeFromArrayTypeNode(node); - case 158: - return getTypeFromTupleTypeNode(node); - case 159: - return getTypeFromUnionTypeNode(node); - case 160: - return getTypeFromIntersectionTypeNode(node); - case 161: - return getTypeFromTypeNode(node.type); case 153: - case 154: + case 263: + return getTypeFromTypeReference(node); + case 152: + return booleanType; + case 192: + return getTypeFromTypeReference(node); case 156: + return getTypeFromTypeQueryNode(node); + case 158: + case 256: + return getTypeFromArrayTypeNode(node); + case 159: + return getTypeFromTupleTypeNode(node); + case 160: + case 257: + return getTypeFromUnionTypeNode(node); + case 161: + return getTypeFromIntersectionTypeNode(node); + case 162: + case 259: + case 260: + case 267: + case 268: + case 264: + return getTypeFromTypeNode(node.type); + case 154: + case 155: + case 157: + case 265: + case 261: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 69: - case 136: + case 137: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); + case 258: + return getTypeFromJSDocTupleType(node); + case 266: + return getTypeFromJSDocVariadicType(node); default: return unknownType; } @@ -15283,6 +15741,7 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = ts.map(signature.typeParameters, cloneTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); @@ -15291,7 +15750,10 @@ var ts; tp.mapper = mapper; } } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper); + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -15349,35 +15811,34 @@ var ts; if (type.flags & 32768) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); } - if (type.flags & 134217728) { - var predicate = type.predicate; - return createPredicateType(type.symbol, cloneTypePredicate(predicate, mapper)); - } } return type; } + function instantiateIndexInfo(info, mapper) { + return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); + } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 176: case 177: + case 178: return isContextSensitiveFunctionLikeDeclaration(node); - case 168: + case 169: return ts.forEach(node.properties, isContextSensitive); - case 167: + case 168: return ts.forEach(node.elements, isContextSensitive); - case 185: + case 186: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 184: + case 185: return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 248: + case 249: return isContextSensitive(node.initializer); + case 145: case 144: - case 143: return isContextSensitiveFunctionLikeDeclaration(node); - case 175: + case 176: return isContextSensitive(node.expression); } return false; @@ -15456,18 +15917,48 @@ var ts; return result; } var sourceReturnType = getReturnTypeOfSignature(source); - if (targetReturnType.flags & 134217728 && targetReturnType.predicate.kind === 1) { - if (!(sourceReturnType.flags & 134217728)) { + if (target.typePredicate) { + if (source.typePredicate) { + result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes); + } + else if (ts.isIdentifierTypePredicate(target.typePredicate)) { if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); } return 0; } } - result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + else { + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + } } return result; } + function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) { + if (source.kind !== target.kind) { + if (reportErrors) { + errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return 0; + } + if (source.kind === 1) { + var sourceIdentifierPredicate = source; + var targetIdentifierPredicate = target; + if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { + if (reportErrors) { + errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return 0; + } + } + var related = compareTypes(source.type, target.type, reportErrors); + if (related === 0 && reportErrors) { + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return related; + } function isImplementationCompatibleWithOverload(implementation, overload) { var erasedSource = getErasedSignature(implementation); var erasedTarget = getErasedSignature(overload); @@ -15563,33 +16054,6 @@ var ts; return -1; } if (source.flags & 8 && target.flags & 8) { - if (source.flags & 134217728 && target.flags & 134217728) { - var sourcePredicate = source; - var targetPredicate = target; - if (sourcePredicate.predicate.kind !== targetPredicate.predicate.kind) { - if (reportErrors) { - reportError(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return 0; - } - if (sourcePredicate.predicate.kind === 1) { - var sourceIdentifierPredicate = sourcePredicate.predicate; - var targetIdentifierPredicate = targetPredicate.predicate; - if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { - if (reportErrors) { - reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return 0; - } - } - var related = isRelatedTo(sourcePredicate.predicate.type, targetPredicate.predicate.type, reportErrors, headMessage); - if (related === 0 && reportErrors) { - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return related; - } return -1; } if (source.flags & 1048576) { @@ -15681,7 +16145,7 @@ var ts; if (type.flags & 80896) { var resolved = resolveStructuredTypeMembers(type); if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || - resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + resolved.stringIndexInfo || resolved.numberIndexInfo || getPropertyOfType(type, name)) { return true; } } @@ -15696,7 +16160,7 @@ var ts; return false; } function hasExcessProperties(source, target, reportErrors) { - if (!(target.flags & 67108864) && someConstituentTypeHasKind(target, 80896)) { + if (!(target.flags & 67108864) && maybeTypeOfKind(target, 80896)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -15839,9 +16303,9 @@ var ts; if (result) { result &= signaturesRelatedTo(source, target, 1, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, 0, reportErrors); if (result) { - result &= numberIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, 1, reportErrors); } } } @@ -15881,23 +16345,23 @@ var ts; else if (!(targetProp.flags & 134217728)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 16 || targetPropFlags & 16) { + if (sourcePropFlags & 8 || targetPropFlags & 8) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 16 && targetPropFlags & 16) { + if (sourcePropFlags & 8 && targetPropFlags & 8) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 ? source : target), typeToString(sourcePropFlags & 16 ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 ? source : target), typeToString(sourcePropFlags & 8 ? target : source)); } } return 0; } } - else if (targetPropFlags & 32) { + else if (targetPropFlags & 16) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; + var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); @@ -15905,7 +16369,7 @@ var ts; return 0; } } - else if (sourcePropFlags & 32) { + else if (sourcePropFlags & 16) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -15963,36 +16427,36 @@ var ts; } var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); - if (kind === 1 && sourceSignatures.length && targetSignatures.length && - isAbstractConstructorType(source) && !isAbstractConstructorType(target)) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + if (kind === 1 && sourceSignatures.length && targetSignatures.length) { + if (isAbstractConstructorType(source) && !isAbstractConstructorType(target)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { + return 0; } - return 0; } var result = -1; var saveErrorInfo = errorInfo; outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { var t = targetSignatures_1[_i]; - if (!t.hasStringLiterals || target.flags & 262144) { - var shouldElaborateErrors = reportErrors; - for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { - var s = sourceSignatures_1[_a]; - if (!s.hasStringLiterals || source.flags & 262144) { - var related = signatureRelatedTo(s, t, shouldElaborateErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; - } - shouldElaborateErrors = false; - } + var shouldElaborateErrors = reportErrors; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; + var related = signatureRelatedTo(s, t, shouldElaborateErrors); + if (related) { + result &= related; + errorInfo = saveErrorInfo; + continue outer; } - if (shouldElaborateErrors) { - reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind)); - } - return 0; + shouldElaborateErrors = false; } + if (shouldElaborateErrors) { + reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind)); + } + return 0; } return result; } @@ -16015,75 +16479,69 @@ var ts; } return result; } - function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0, source, target); - } - var targetType = getIndexTypeOfType(target, 0); - if (targetType) { - if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { - return -1; - } - var sourceType = getIndexTypeOfType(source, 0); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + function eachPropertyRelatedTo(source, target, kind, reportErrors) { + var result = -1; + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (kind === 0 || isNumericLiteralName(prop.name)) { + var related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); + } + return 0; } - return 0; + result &= related; } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0; - } - return related; } - return -1; + return result; } - function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1, source, target); + function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { + var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors); + if (!related && reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); } - var targetType = getIndexTypeOfType(target, 1); - if (targetType) { - if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { - return -1; - } - var sourceStringType = getIndexTypeOfType(source, 0); - var sourceNumberType = getIndexTypeOfType(source, 1); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0; - } - var related; - if (sourceStringType && sourceNumberType) { - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0; - } - return related; - } - return -1; + return related; } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { + function indexTypesRelatedTo(source, originalSource, target, kind, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(source, target, kind); + } + var targetInfo = getIndexInfoOfType(target, kind); + if (!targetInfo || ((targetInfo.type.flags & 1) && !(originalSource.flags & 16777726))) { return -1; } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); + var sourceInfo = getIndexInfoOfType(source, kind) || + kind === 1 && getIndexInfoOfType(source, 0); + if (sourceInfo) { + return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); + } + if (isObjectLiteralType(source)) { + var related = -1; + if (kind === 0) { + var sourceNumberInfo = getIndexInfoOfType(source, 1); + if (sourceNumberInfo) { + related = indexInfoRelatedTo(sourceNumberInfo, targetInfo, reportErrors); + } + } + if (related) { + related &= eachPropertyRelatedTo(source, targetInfo.type, kind, reportErrors); + } + return related; + } + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0; + } + function indexTypesIdenticalTo(source, target, indexKind) { + var targetInfo = getIndexInfoOfType(target, indexKind); + var sourceInfo = getIndexInfoOfType(source, indexKind); + if (!sourceInfo && !targetInfo) { + return -1; + } + if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) { + return isRelatedTo(sourceInfo.type, targetInfo.type); } return 0; } @@ -16106,6 +16564,26 @@ var ts; } return -1; } + function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { + if (!sourceSignature.declaration || !targetSignature.declaration) { + return true; + } + var sourceAccessibility = sourceSignature.declaration.flags & (8 | 16); + var targetAccessibility = targetSignature.declaration.flags & (8 | 16); + if (targetAccessibility === 8) { + return true; + } + if (targetAccessibility === 16 && sourceAccessibility !== 8) { + return true; + } + if (targetAccessibility !== 16 && !sourceAccessibility) { + return true; + } + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility)); + } + return false; + } } function isAbstractConstructorType(type) { if (type.flags & 65536) { @@ -16141,8 +16619,8 @@ var ts; if (sourceProp === targetProp) { return -1; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 | 32); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 | 32); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (8 | 16); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (8 | 16); if (sourcePropAccessibility !== targetPropAccessibility) { return 0; } @@ -16156,6 +16634,9 @@ var ts; return 0; } } + if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { + return 0; + } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { @@ -16243,7 +16724,8 @@ var ts; return type.flags & 4096 && type.target === globalArrayType; } function isArrayLikeType(type) { - return !(type.flags & (32 | 64)) && isTypeAssignableTo(type, anyArrayType); + return type.flags & 4096 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || + !(type.flags & (32 | 64)) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isTupleLikeType(type) { return !!getPropertyOfType(type, "0"); @@ -16254,6 +16736,11 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192); } + function isObjectLiteralType(type) { + return type.symbol && (type.symbol.flags & (4096 | 2048)) !== 0 && + getSignaturesOfType(type, 0).length === 0 && + getSignaturesOfType(type, 1).length === 0; + } function getRegularTypeOfObjectLiteral(type) { if (type.flags & 1048576) { var regularType = type.regularType; @@ -16264,8 +16751,8 @@ var ts; regularType.properties = type.properties; regularType.callSignatures = type.callSignatures; regularType.constructSignatures = type.constructSignatures; - regularType.stringIndexType = type.stringIndexType; - regularType.numberIndexType = type.numberIndexType; + regularType.stringIndexInfo = type.stringIndexInfo; + regularType.numberIndexInfo = type.numberIndexInfo; type.regularType = regularType; } return regularType; @@ -16290,22 +16777,15 @@ var ts; } members[p.name] = p; }); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndexInfo = getIndexInfoOfType(type, 0); + var numberIndexInfo = getIndexInfoOfType(type, 1); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); } function getWidenedType(type) { - if (type.flags & 140509184) { + if (type.flags & 6291456) { if (type.flags & (32 | 64)) { return anyType; } - if (type.flags & 134217728) { - return booleanType; - } if (type.flags & 524288) { return getWidenedTypeOfObjectLiteral(type); } @@ -16360,22 +16840,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 143: case 142: - case 141: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 139: + case 140: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 216: + case 217: + case 145: case 144: - case 143: - case 146: case 147: - case 176: + case 148: case 177: + case 178: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16441,6 +16921,7 @@ var ts; var targetStack; var depth = 0; var inferiority = 0; + var visited = {}; inferFromTypes(source, target); function isInProcess(source, target) { for (var i = 0; i < depth; i++) { @@ -16494,11 +16975,6 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (source.flags & 134217728 && target.flags & 134217728) { - if (source.predicate.kind === target.predicate.kind) { - inferFromTypes(source.predicate.type, target.predicate.type); - } - } else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { var sourceTypes = source.elementTypes; var targetTypes = target.elementTypes; @@ -16544,6 +17020,11 @@ var ts; if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { return; } + var key = source.id + "," + target.id; + if (ts.hasProperty(visited, key)) { + return; + } + visited[key] = true; if (depth === 0) { sourceStack = []; targetStack = []; @@ -16554,9 +17035,7 @@ var ts; inferFromProperties(source, target); inferFromSignatures(source, target, 0); inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); + inferFromIndexTypes(source, target); depth--; } } @@ -16583,14 +17062,29 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate && source.typePredicate.kind === target.typePredicate.kind) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } - function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); + function inferFromIndexTypes(source, target) { + var targetStringIndexType = getIndexTypeOfType(target, 0); + if (targetStringIndexType) { + var sourceIndexType = getIndexTypeOfType(source, 0) || + getImplicitIndexTypeOfType(source, 0); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); + inferFromTypes(sourceIndexType, targetStringIndexType); + } + } + var targetNumberIndexType = getIndexTypeOfType(target, 1); + if (targetNumberIndexType) { + var sourceIndexType = getIndexTypeOfType(source, 1) || + getIndexTypeOfType(source, 0) || + getImplicitIndexTypeOfType(source, 1); + if (sourceIndexType) { + inferFromTypes(sourceIndexType, targetNumberIndexType); } } } @@ -16664,10 +17158,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 155: + case 156: return true; case 69: - case 136: + case 137: node = node.parent; continue; default: @@ -16708,55 +17202,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 184: + case 185: return isAssignedInBinaryExpression(node); - case 214: - case 166: - return isAssignedInVariableDeclaration(node); - case 164: - case 165: + case 215: case 167: + return isAssignedInVariableDeclaration(node); + case 165: + case 166: case 168: case 169: case 170: case 171: case 172: - case 174: - case 192: + case 173: case 175: - case 182: - case 178: - case 181: - case 179: - case 180: + case 193: + case 176: case 183: - case 187: - case 185: + case 179: + case 182: + case 180: + case 181: + case 184: case 188: - case 195: + case 186: + case 189: case 196: - case 198: + case 197: case 199: case 200: case 201: case 202: case 203: case 204: - case 207: + case 205: case 208: case 209: - case 244: - case 245: case 210: + case 245: + case 246: case 211: case 212: - case 247: - case 236: + case 213: + case 248: case 237: - case 241: - case 242: case 238: + case 242: case 243: + case 239: + case 244: return ts.forEachChild(node, isAssignedIn); } return false; @@ -16766,7 +17260,7 @@ var ts; var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { - var declaration = ts.getDeclarationOfKind(symbol, 214); + var declaration = ts.getDeclarationOfKind(symbol, 215); var top_1 = declaration && getDeclarationContainer(declaration); var originalType = type; var nodeStack = []; @@ -16774,13 +17268,13 @@ var ts; var child = node; node = node.parent; switch (node.kind) { - case 199: + case 200: + case 186: case 185: - case 184: nodeStack.push({ node: node, child: child }); break; - case 251: - case 221: + case 252: + case 222: break loop; } if (node === top_1) { @@ -16791,17 +17285,17 @@ var ts; while (nodes = nodeStack.pop()) { var node_1 = nodes.node, child = nodes.child; switch (node_1.kind) { - case 199: + case 200: if (child !== node_1.expression) { type = narrowType(type, node_1.expression, child === node_1.thenStatement); } break; - case 185: + case 186: if (child !== node_1.condition) { type = narrowType(type, node_1.condition, child === node_1.whenTrue); } break; - case 184: + case 185: if (child === node_1.right) { if (node_1.operatorToken.kind === 51) { type = narrowType(type, node_1.left, true); @@ -16825,7 +17319,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 179 || expr.right.kind !== 9) { + if (expr.left.kind !== 180 || expr.right.kind !== 9) { return type; } var left = expr.left; @@ -16932,42 +17426,30 @@ var ts; } return originalType; } - function narrowTypeByTypePredicate(type, expr, assumeTrue) { + function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { if (type.flags & 1) { return type; } - var signature = getResolvedSignature(expr); - var predicateType = getReturnTypeOfSignature(signature); - if (!predicateType || !(predicateType.flags & 134217728)) { + var signature = getResolvedSignature(callExpression); + var predicate = signature.typePredicate; + if (!predicate) { return type; } - var predicate = predicateType.predicate; if (ts.isIdentifierTypePredicate(predicate)) { - var callExpression = expr; if (callExpression.arguments[predicate.parameterIndex] && getSymbolAtTypePredicatePosition(callExpression.arguments[predicate.parameterIndex]) === symbol) { return getNarrowedType(type, predicate.type, assumeTrue); } } else { - var expression = skipParenthesizedNodes(expr.expression); - return narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue); + var invokedExpression = skipParenthesizedNodes(callExpression.expression); + return narrowTypeByThisTypePredicate(type, predicate, invokedExpression, assumeTrue); } return type; } - function narrowTypeByTypePredicateMember(type, expr, assumeTrue) { - if (type.flags & 1) { - return type; - } - var memberType = getTypeOfExpression(expr); - if (!(memberType.flags & 134217728)) { - return type; - } - return narrowTypeByThisTypePredicate(type, memberType.predicate, expr, assumeTrue); - } - function narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue) { - if (expression.kind === 170 || expression.kind === 169) { - var accessExpression = expression; + function narrowTypeByThisTypePredicate(type, predicate, invokedExpression, assumeTrue) { + if (invokedExpression.kind === 171 || invokedExpression.kind === 170) { + var accessExpression = invokedExpression; var possibleIdentifier = skipParenthesizedNodes(accessExpression.expression); if (possibleIdentifier.kind === 69 && getSymbolAtTypePredicatePosition(possibleIdentifier) === symbol) { return getNarrowedType(type, predicate.type, assumeTrue); @@ -16979,18 +17461,17 @@ var ts; expr = skipParenthesizedNodes(expr); switch (expr.kind) { case 69: - case 169: - case 136: + case 170: return getSymbolOfEntityNameOrPropertyAccessExpression(expr); } } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 171: + case 172: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 175: + case 176: return narrowType(type, expr.expression, assumeTrue); - case 184: + case 185: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -17005,20 +17486,17 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 182: + case 183: if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; - case 170: - case 169: - return narrowTypeByTypePredicateMember(type, expr, assumeTrue); } return type; } } function skipParenthesizedNodes(expression) { - while (expression.kind === 175) { + while (expression.kind === 176) { expression = expression.expression; } return expression; @@ -17027,23 +17505,37 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 177) { + if (container.kind === 178) { 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); } } - if (node.parserContextFlags & 8) { - getNodeLinks(container).flags |= 4096; - getNodeLinks(node).flags |= 2048; + if (node.flags & 33554432) { + getNodeLinks(container).flags |= 8192; } } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); } + var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); + if (languageVersion === 2 + && localOrExportSymbol.flags & 32 + && localOrExportSymbol.valueDeclaration.kind === 218 + && ts.nodeIsDecorated(localOrExportSymbol.valueDeclaration)) { + var container = ts.getContainingClass(node); + while (container !== undefined) { + if (container === localOrExportSymbol.valueDeclaration && container.name !== node) { + getNodeLinks(container).flags |= 524288; + getNodeLinks(node).flags |= 1048576; + break; + } + container = ts.getContainingClass(container); + } + } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); - checkBlockScopedBindingCapturedInLoop(node, symbol); - return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); + checkNestedBlockScopedBinding(node, symbol); + return getNarrowedTypeOfSymbol(localOrExportSymbol, node); } function isInsideFunction(node, threshold) { var current = node; @@ -17055,42 +17547,67 @@ var ts; } return false; } - function checkBlockScopedBindingCapturedInLoop(node, symbol) { + function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 247) { + symbol.valueDeclaration.parent.kind === 248) { return; } - var container; - if (symbol.flags & 32) { - container = getClassLikeDeclarationOfSymbol(symbol).parent; - } - else { - container = symbol.valueDeclaration; - while (container.kind !== 215) { - container = container.parent; - } - container = container.parent; - if (container.kind === 196) { - container = container.parent; - } - } - var inFunction = isInsideFunction(node.parent, container); + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + var usedInFunction = isInsideFunction(node.parent, container); var current = container; + var containedInIterationStatement = false; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { if (ts.isIterationStatement(current, false)) { - if (inFunction) { - getNodeLinks(current).flags |= 65536; - } - getNodeLinks(symbol.valueDeclaration).flags |= 16384; + containedInIterationStatement = true; break; } current = current.parent; } + if (containedInIterationStatement) { + if (usedInFunction) { + getNodeLinks(current).flags |= 65536; + } + if (container.kind === 203 && + ts.getAncestor(symbol.valueDeclaration, 216).parent === container && + isAssignedInBodyOfForStatement(node, container)) { + getNodeLinks(symbol.valueDeclaration).flags |= 2097152; + } + getNodeLinks(symbol.valueDeclaration).flags |= 262144; + } + if (usedInFunction) { + getNodeLinks(symbol.valueDeclaration).flags |= 131072; + } + } + function isAssignedInBodyOfForStatement(node, container) { + var current = node; + while (current.parent.kind === 176) { + current = current.parent; + } + var isAssigned = false; + if (current.parent.kind === 185) { + isAssigned = current.parent.left === current && ts.isAssignmentOperator(current.parent.operatorToken.kind); + } + if ((current.parent.kind === 183 || current.parent.kind === 184)) { + var expr = current.parent; + isAssigned = expr.operator === 41 || expr.operator === 42; + } + if (!isAssigned) { + return false; + } + while (current !== container) { + if (current === container.statement) { + return true; + } + else { + current = current.parent; + } + } + return false; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 142 || container.kind === 145) { + if (container.kind === 143 || container.kind === 146) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -17098,32 +17615,65 @@ var ts; getNodeLinks(container).flags |= 4; } } + function findFirstSuperCall(n) { + if (ts.isSuperCallExpression(n)) { + return n; + } + else if (ts.isFunctionLike(n)) { + return undefined; + } + return ts.forEachChild(n, findFirstSuperCall); + } + function getSuperCallInConstructor(constructor) { + var links = getNodeLinks(constructor); + if (links.hasSuperCall === undefined) { + links.superCall = findFirstSuperCall(constructor.body); + links.hasSuperCall = links.superCall ? true : false; + } + return links.superCall; + } + function classDeclarationExtendsNull(classDecl) { + var classSymbol = getSymbolOfNode(classDecl); + var classInstanceType = getDeclaredTypeOfSymbol(classSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType); + return baseConstructorType === nullType; + } function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 177) { + if (container.kind === 146) { + var containingClassDecl = container.parent; + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { + var superCall = getSuperCallInConstructor(container); + if (!superCall || superCall.end > node.pos) { + error(node, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); + } + } + } + if (container.kind === 178) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 221: + case 222: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 220: + case 221: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 145: + case 146: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 143: case 142: - case 141: - if (container.flags & 64) { + if (container.flags & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 137: + case 138: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -17132,36 +17682,51 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 64 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 32 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } - if (ts.isInJavaScriptFile(node) && container.kind === 176) { - if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { - var className = container.parent - .left - .expression - .expression; - var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) { - return getInferredClassType(classSymbol); + if (ts.isInJavaScriptFile(node)) { + var type = getTypeForThisExpressionFromJSDoc(container); + if (type && type !== unknownType) { + return type; + } + if (container.kind === 177) { + if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { + var className = container.parent + .left + .expression + .expression; + var classSymbol = checkExpression(className).symbol; + if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) { + return getInferredClassType(classSymbol); + } } } } return anyType; } + function getTypeForThisExpressionFromJSDoc(node) { + var typeTag = ts.getJSDocTypeTag(node); + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 265) { + var jsDocFunctionType = typeTag.typeExpression.type; + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 268) { + return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); + } + } + } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 139) { + if (n.kind === 140) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 171 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 172 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 177) { + while (container && container.kind === 178) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -17170,16 +17735,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 137) { + while (current && current !== container && current.kind !== 138) { current = current.parent; } - if (current && current.kind === 137) { + if (current && current.kind === 138) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 168)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 169)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -17187,17 +17752,25 @@ var ts; } return unknownType; } - if ((container.flags & 64) || isCallExpression) { + if ((container.flags & 32) || isCallExpression) { nodeCheckFlag = 512; } else { nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; + if (container.kind === 145 && container.flags & 256) { + if (ts.isSuperPropertyOrElementAccess(node.parent) && isAssignmentTarget(node.parent)) { + getNodeLinks(container).flags |= 4096; + } + else { + getNodeLinks(container).flags |= 2048; + } + } if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 168) { + if (container.parent.kind === 169) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -17215,7 +17788,7 @@ var ts; } return unknownType; } - if (container.kind === 145 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 146 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -17227,24 +17800,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 145; + return container.kind === 146; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 168) { - if (container.flags & 64) { - return container.kind === 144 || - container.kind === 143 || - container.kind === 146 || - container.kind === 147; + if (ts.isClassLike(container.parent) || container.parent.kind === 169) { + if (container.flags & 32) { + return container.kind === 145 || + container.kind === 144 || + container.kind === 147 || + container.kind === 148; } else { - return container.kind === 144 || - container.kind === 143 || - container.kind === 146 || + return container.kind === 145 || + container.kind === 144 || container.kind === 147 || + container.kind === 148 || + container.kind === 143 || container.kind === 142 || - container.kind === 141 || - container.kind === 145; + container.kind === 146; } } } @@ -17279,7 +17852,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 139) { + if (declaration.kind === 140) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17312,7 +17885,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 139 && node.parent.initializer === node) { + if (node.parent.kind === 140 && node.parent.initializer === node) { return true; } node = node.parent; @@ -17321,8 +17894,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 145 || - functionDecl.kind === 146 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 147))) { + functionDecl.kind === 146 || + functionDecl.kind === 147 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 148))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -17341,7 +17914,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 173) { + if (template.parent.kind === 174) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17407,9 +17980,6 @@ var ts; function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } - function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); - } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); if (isInsideWithStatementBody(node)) { @@ -17452,13 +18022,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 241) { + if (attribute.kind === 242) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 242) { + else if (attribute.kind === 243) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -17476,40 +18046,40 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 214: - case 139: + case 215: + case 140: + case 143: case 142: - case 141: - case 166: - return getContextualTypeForInitializerExpression(node); - case 177: - case 207: - return getContextualTypeForReturnExpression(node); - case 187: - return getContextualTypeForYieldOperand(parent); - case 171: - case 172: - return getContextualTypeForArgument(parent, node); - case 174: - case 192: - return getTypeFromTypeNode(parent.type); - case 184: - return getContextualTypeForBinaryOperand(node); - case 248: - return getContextualTypeForObjectLiteralElement(parent); case 167: - return getContextualTypeForElementExpression(node); - case 185: - return getContextualTypeForConditionalOperand(node); - case 193: - ts.Debug.assert(parent.parent.kind === 186); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 178: + case 208: + return getContextualTypeForReturnExpression(node); + case 188: + return getContextualTypeForYieldOperand(parent); + case 172: + case 173: + return getContextualTypeForArgument(parent, node); case 175: + case 193: + return getTypeFromTypeNode(parent.type); + case 185: + return getContextualTypeForBinaryOperand(node); + case 249: + return getContextualTypeForObjectLiteralElement(parent); + case 168: + return getContextualTypeForElementExpression(node); + case 186: + return getContextualTypeForConditionalOperand(node); + case 194: + ts.Debug.assert(parent.parent.kind === 187); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 176: return getContextualType(parent); - case 243: + case 244: return getContextualType(parent); - case 241: case 242: + case 243: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -17524,7 +18094,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 176 || node.kind === 177; + return node.kind === 177 || node.kind === 178; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -17532,7 +18102,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getApparentTypeOfContextualType(node); @@ -17572,13 +18142,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 184 && parent.operatorToken.kind === 56 && parent.left === node) { + if (parent.kind === 185 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 248) { + if (parent.kind === 249) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 167) { + if (parent.kind === 168) { return isAssignmentTarget(parent); } return false; @@ -17588,8 +18158,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 166 && !!node.initializer) || - (node.kind === 184 && node.operatorToken.kind === 56); + return (node.kind === 167 && !!node.initializer) || + (node.kind === 185 && node.operatorToken.kind === 56); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -17598,7 +18168,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 188) { + if (inDestructuringPattern && e.kind === 189) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -17610,7 +18180,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 188; + hasSpreadElement = hasSpreadElement || e.kind === 189; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -17621,7 +18191,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 165 || pattern.kind === 167)) { + if (pattern && (pattern.kind === 166 || pattern.kind === 168)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -17629,7 +18199,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 190) { + if (patternElement.kind !== 191) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -17644,13 +18214,13 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 137 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 138 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); } function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); + return isTypeAny(type) || isTypeOfKind(type, kind); } function isNumericLiteralName(name) { return (+name).toString() === name; @@ -17668,6 +18238,16 @@ var ts; } return links.resolvedType; } + function getObjectLiteralIndexInfo(node, properties, kind) { + var propTypes = []; + for (var i = 0; i < properties.length; i++) { + if (kind === 0 || isNumericName(node.properties[i].name)) { + propTypes.push(getTypeOfSymbol(properties[i])); + } + } + var unionType = propTypes.length ? getUnionType(propTypes) : undefinedType; + return createIndexInfo(unionType, false); + } function checkObjectLiteral(node, contextualMapper) { var inDestructuringPattern = isAssignmentTarget(node); checkGrammarObjectLiteralExpression(node, inDestructuringPattern); @@ -17675,31 +18255,33 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 164 || contextualType.pattern.kind === 168); + (contextualType.pattern.kind === 165 || contextualType.pattern.kind === 169); var typeFlags = 0; var patternWithComputedProperties = false; + var hasComputedStringProperty = false; + var hasComputedNumberProperty = false; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 248 || - memberDecl.kind === 249 || + if (memberDecl.kind === 249 || + memberDecl.kind === 250 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 248) { + if (memberDecl.kind === 249) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 144) { + else if (memberDecl.kind === 145) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 249); + ts.Debug.assert(memberDecl.kind === 250); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 248 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 249 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 249 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 250 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -17726,10 +18308,18 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 146 || memberDecl.kind === 147); + ts.Debug.assert(memberDecl.kind === 147 || memberDecl.kind === 148); checkAccessorDeclaration(memberDecl); } - if (!ts.hasDynamicName(memberDecl)) { + if (ts.hasDynamicName(memberDecl)) { + if (isNumericName(memberDecl.name)) { + hasComputedNumberProperty = true; + } + else { + hasComputedStringProperty = true; + } + } + else { propertiesTable[member.name] = member; } propertiesArray.push(member); @@ -17746,33 +18336,15 @@ var ts; } } } - var stringIndexType = getIndexType(0); - var numberIndexType = getIndexType(1); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064) | (patternWithComputedProperties ? 67108864 : 0); if (inDestructuringPattern) { result.pattern = node; } return result; - function getIndexType(kind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - var propTypes = []; - for (var i = 0; i < propertiesArray.length; i++) { - var propertyDecl = node.properties[i]; - if (kind === 0 || isNumericName(propertyDecl.name)) { - var type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, type)) { - propTypes.push(type); - } - } - } - var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= result_1.flags; - return result_1; - } - return undefined; - } } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -17780,17 +18352,17 @@ var ts; } function checkJsxElement(node) { checkJsxOpeningLikeElement(node.openingElement); - getJsxElementTagSymbol(node.closingElement); + getJsxTagSymbol(node.closingElement); for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 243: + case 244: checkJsxExpression(child); break; - case 236: + case 237: checkJsxElement(child); break; - case 237: + case 238: checkJsxSelfClosingElement(child); break; } @@ -17801,7 +18373,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 136) { + if (tagName.kind === 137) { return false; } else { @@ -17864,68 +18436,43 @@ var ts; } return jsxTypes[name]; } - function getJsxElementTagSymbol(node) { + function getJsxTagSymbol(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicTagSymbol(node); + } + else { + return checkExpression(node.tagName).symbol; + } + } + function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - links.resolvedSymbol = lookupIntrinsicTag(node); - } - else { - links.resolvedSymbol = lookupClassTag(node); - } - } - return links.resolvedSymbol; - function lookupIntrinsicTag(node) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); if (intrinsicProp) { links.jsxFlags |= 1; - return intrinsicProp; + return links.resolvedSymbol = intrinsicProp; } var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); if (indexSignatureType) { links.jsxFlags |= 2; - return intrinsicElementsType.symbol; + return links.resolvedSymbol = intrinsicElementsType.symbol; } error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); - return unknownSymbol; + return links.resolvedSymbol = unknownSymbol; } else { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } - return unknownSymbol; - } - } - function lookupClassTag(node) { - var valueSymbol = resolveJsxTagName(node); - if (valueSymbol && valueSymbol !== unknownSymbol) { - links.jsxFlags |= 4; - if (valueSymbol.flags & 8388608) { - markAliasSymbolAsReferenced(valueSymbol); - } - } - return valueSymbol || unknownSymbol; - } - function resolveJsxTagName(node) { - if (node.tagName.kind === 69) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - return sym.exportSymbol || sym; - } - else { - return checkQualifiedName(node.tagName).symbol; + return links.resolvedSymbol = unknownSymbol; } } + return links.resolvedSymbol; } function getJsxElementInstanceType(node) { - ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); - var classSymbol = getJsxElementTagSymbol(node); - if (classSymbol === unknownSymbol) { - return anyType; - } - var valueType = getTypeOfSymbol(classSymbol); + var valueType = checkExpression(node.tagName); if (isTypeAny(valueType)) { return anyType; } @@ -17963,12 +18510,20 @@ var ts; function getJsxElementAttributesType(node) { var links = getNodeLinks(node); if (!links.resolvedJsxType) { - var sym = getJsxElementTagSymbol(node); - if (links.jsxFlags & 4) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1) { + return links.resolvedJsxType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0).type; + } + } + else { var elemInstanceType = getJsxElementInstanceType(node); var elemClassType = getJsxGlobalElementClassType(); if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - var elemType = getTypeOfSymbol(sym); + var elemType = checkExpression(node.tagName); var callSignatures = elemType && getSignaturesOfType(elemType, 0); var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); @@ -18028,15 +18583,7 @@ var ts; } } } - else if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(sym); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0); - } - else { - return links.resolvedJsxType = anyType; - } + return links.resolvedJsxType = unknownType; } return links.resolvedJsxType; } @@ -18078,11 +18625,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 241) { + if (node.attributes[i].kind === 242) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 242); + ts.Debug.assert(node.attributes[i].kind === 243); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -18108,19 +18655,19 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 142; + return s.valueDeclaration ? s.valueDeclaration.kind : 143; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 8 | 64 : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; } function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); if (left.kind === 95) { - var errorNode = node.kind === 169 ? + var errorNode = node.kind === 170 ? node.name : node.right; - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 144) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 145) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -18129,12 +18676,12 @@ var ts; return false; } } - if (!(flags & (16 | 32))) { + if (!(flags & (8 | 16))) { return true; } var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - if (flags & 16) { + if (flags & 8) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -18148,7 +18695,7 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); return false; } - if (flags & 64) { + if (flags & 32) { return true; } if (type.flags & 33554432) { @@ -18189,7 +18736,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 169 + var left = node.kind === 170 ? node.expression : node.left; var type = checkExpression(left); @@ -18203,7 +18750,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 215) { + if (initializer.kind === 216) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -18225,7 +18772,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 203 && + if (node.kind === 204 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -18241,7 +18788,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 172 && node.parent.expression === node) { + if (node.parent.kind === 173 && 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); @@ -18279,14 +18826,16 @@ var ts; } if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { - var numberIndexType = getIndexTypeOfType(objectType, 1); - if (numberIndexType) { - return numberIndexType; + var numberIndexInfo = getIndexInfoOfType(objectType, 1); + if (numberIndexInfo) { + getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; + return numberIndexInfo.type; } } - var stringIndexType = getIndexTypeOfType(objectType, 0); - if (stringIndexType) { - return stringIndexType; + var stringIndexInfo = getIndexInfoOfType(objectType, 0); + if (stringIndexInfo) { + getNodeLinks(node).resolvedIndexInfo = stringIndexInfo; + return stringIndexInfo.type; } if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { error(node, getIndexTypeOfType(objectType, 1) ? @@ -18302,7 +18851,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 170 || indexArgumentExpression.kind === 169) { + if (indexArgumentExpression.kind === 171 || indexArgumentExpression.kind === 170) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -18345,10 +18894,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 173) { + if (node.kind === 174) { checkExpression(node.template); } - else if (node.kind !== 140) { + else if (node.kind !== 141) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -18370,19 +18919,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_5 = signature.declaration && signature.declaration.parent; + var parent_6 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_5 === lastParent) { + if (lastParent && parent_6 === lastParent) { index++; } else { - lastParent = parent_5; + lastParent = parent_6; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_5; + lastParent = parent_6; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -18399,7 +18948,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 188) { + if (arg && arg.kind === 189) { return i; } } @@ -18411,11 +18960,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 173) { + if (node.kind === 174) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 186) { + if (tagExpression.template.kind === 187) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -18427,7 +18976,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 140) { + else if (node.kind === 141) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -18435,7 +18984,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 172); + ts.Debug.assert(callExpression.kind === 173); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -18461,7 +19010,7 @@ var ts; if (type.flags & 80896) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { return resolved.callSignatures[0]; } } @@ -18488,7 +19037,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 !== 190) { + if (arg === undefined || arg.kind !== 191) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -18537,7 +19086,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 !== 190) { + if (arg === undefined || arg.kind !== 191) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -18556,16 +19105,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 173) { + if (node.kind === 174) { var template = node.template; args = [undefined]; - if (template.kind === 186) { + if (template.kind === 187) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 140) { + else if (node.kind === 141) { return undefined; } else { @@ -18574,21 +19123,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 140) { + if (node.kind === 141) { switch (node.parent.kind) { - case 217: - case 189: + case 218: + case 190: return 1; - case 142: + case 143: return 2; - case 144: - case 146: + case 145: case 147: + case 148: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 139: + case 140: return 3; } } @@ -18597,50 +19146,50 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 217) { + if (node.kind === 218) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 139) { + if (node.kind === 140) { node = node.parent; - if (node.kind === 145) { + if (node.kind === 146) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 142 || - node.kind === 144 || - node.kind === 146 || - node.kind === 147) { + if (node.kind === 143 || + node.kind === 145 || + node.kind === 147 || + node.kind === 148) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 217) { + if (node.kind === 218) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 139) { + if (node.kind === 140) { node = node.parent; - if (node.kind === 145) { + if (node.kind === 146) { return anyType; } } - if (node.kind === 142 || - node.kind === 144 || - node.kind === 146 || - node.kind === 147) { + if (node.kind === 143 || + node.kind === 145 || + node.kind === 147 || + node.kind === 148) { var element = node; switch (element.name.kind) { case 69: case 8: case 9: return getStringLiteralTypeForText(element.name.text); - case 137: + case 138: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216)) { + if (isTypeOfKind(nameType, 16777216)) { return nameType; } else { @@ -18655,20 +19204,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 217) { + if (node.kind === 218) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 139) { + if (node.kind === 140) { return numberType; } - if (node.kind === 142) { + if (node.kind === 143) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144 || - node.kind === 146 || - node.kind === 147) { + if (node.kind === 145 || + node.kind === 147 || + node.kind === 148) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -18689,26 +19238,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 140) { + if (node.kind === 141) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 173) { + else if (argIndex === 0 && node.kind === 174) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 140 || - (argIndex === 0 && node.kind === 173)) { + if (node.kind === 141 || + (argIndex === 0 && node.kind === 174)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 140) { + if (node.kind === 141) { return node.expression; } - else if (argIndex === 0 && node.kind === 173) { + else if (argIndex === 0 && node.kind === 174) { return node.template; } else { @@ -18716,8 +19265,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 173; - var isDecorator = node.kind === 140; + var isTaggedTemplate = node.kind === 174; + var isDecorator = node.kind === 141; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -18864,8 +19413,10 @@ var ts; var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); - return resolveCall(node, baseConstructors, candidatesOutArray); + if (baseTypeNode) { + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); + } } return resolveUntypedCall(node); } @@ -18918,6 +19469,9 @@ var ts; } var constructSignatures = getSignaturesOfType(expressionType, 1); if (constructSignatures.length) { + if (!isConstructorAccessible(node, constructSignatures[0])) { + return resolveErrorCall(node); + } return resolveCall(node, constructSignatures, candidatesOutArray); } var callSignatures = getSignaturesOfType(expressionType, 0); @@ -18931,6 +19485,28 @@ var ts; error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); return resolveErrorCall(node); } + function isConstructorAccessible(node, signature) { + if (!signature || !signature.declaration) { + return true; + } + var declaration = signature.declaration; + var flags = declaration.flags; + if (!(flags & (8 | 16))) { + return true; + } + var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); + var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol); + if (!isNodeWithinClass(node, declaringClassDeclaration)) { + if (flags & 8) { + error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); + } + if (flags & 16) { + error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); + } + return false; + } + return true; + } function resolveTaggedTemplateExpression(node, candidatesOutArray) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); @@ -18949,16 +19525,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 217: - case 189: + case 218: + case 190: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 139: + case 140: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 144: - case 146: + case 145: case 147: + case 148: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -18986,16 +19562,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 171) { + if (node.kind === 172) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 172) { + else if (node.kind === 173) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 173) { + else if (node.kind === 174) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 140) { + else if (node.kind === 141) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -19017,12 +19593,13 @@ var ts; if (node.expression.kind === 95) { return voidType; } - if (node.kind === 172) { + if (node.kind === 173) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 145 && - declaration.kind !== 149 && - declaration.kind !== 154) { + declaration.kind !== 146 && + declaration.kind !== 150 && + declaration.kind !== 155 && + !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16)) { return getInferredClassType(funcSymbol); @@ -19033,7 +19610,7 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, true)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -19046,8 +19623,8 @@ var ts; var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); - var bothAreStringLike = someConstituentTypeHasKind(targetType, 258) && - someConstituentTypeHasKind(widenedType, 258); + var bothAreStringLike = maybeTypeOfKind(targetType, 258) && + maybeTypeOfKind(widenedType, 258); if (!bothAreStringLike && !(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } @@ -19076,7 +19653,7 @@ var ts; if (ts.isBindingPattern(node.name)) { for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 190) { + if (element.kind !== 191) { if (element.name.kind === 69) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } @@ -19095,6 +19672,13 @@ var ts; inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } + function getReturnTypeFromJSDocComment(func) { + var returnTag = ts.getJSDocReturnTag(func); + if (returnTag && returnTag.typeExpression) { + return getTypeFromTypeNode(returnTag.typeExpression.type); + } + return undefined; + } function createPromiseType(promisedType) { var globalPromiseType = getGlobalPromiseType(); if (globalPromiseType !== emptyGenericType) { @@ -19110,7 +19694,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 195) { + if (func.body.kind !== 196) { 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); @@ -19153,7 +19737,7 @@ var ts; } else { error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; + return getUnionType(types); } } if (funcIsGenerator) { @@ -19212,13 +19796,13 @@ var ts; if (!produceDiagnostics) { return; } - if (returnType === voidType || isTypeAny(returnType)) { + if (returnType && maybeTypeOfKind(returnType, 1 | 16)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 195 || !(func.flags & 524288)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 196 || !(func.flags & 32768)) { return; } - var hasExplicitReturn = func.flags & 1048576; + var hasExplicitReturn = func.flags & 65536; if (returnType && !hasExplicitReturn) { error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } @@ -19235,9 +19819,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 176) { + if (!hasGrammarError && node.kind === 177) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -19270,14 +19854,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 144 && node.kind !== 143) { + if (produceDiagnostics && node.kind !== 145 && node.kind !== 144) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -19287,7 +19871,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 195) { + if (node.body.kind === 196) { checkSourceElement(node.body); } else { @@ -19311,59 +19895,62 @@ var ts; } return true; } - function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { - function findSymbol(n) { - var symbol = getNodeLinks(n).resolvedSymbol; - return symbol && getExportSymbolOfValueSymbolIfExported(symbol); + function isReadonlySymbol(symbol) { + return symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 || + symbol.flags & 3 && (getDeclarationFlagsFromSymbol(symbol) & 2048) !== 0 || + symbol.flags & 98304 && !(symbol.flags & 65536) || + (symbol.flags & 8) !== 0; + } + function isReferenceToReadonlyEntity(expr, symbol) { + if (isReadonlySymbol(symbol)) { + if (symbol.flags & 4 && + (expr.kind === 170 || expr.kind === 171) && + expr.expression.kind === 97) { + var func = ts.getContainingFunction(expr); + return !(func && func.kind === 146 && func.parent === symbol.valueDeclaration.parent); + } + return true; } - function isReferenceOrErrorExpression(n) { - switch (n.kind) { - case 69: { - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; + return false; + } + function isReferenceThroughNamespaceImport(expr) { + if (expr.kind === 170 || expr.kind === 171) { + var node = skipParenthesizedNodes(expr.expression); + if (node.kind === 69) { + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol.flags & 8388608) { + var declaration = getDeclarationOfAliasSymbol(symbol); + return declaration && declaration.kind === 228; } - case 169: { - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; - } - case 170: - return true; - case 175: - return isReferenceOrErrorExpression(n.expression); - default: - return false; } } - function isConstVariableReference(n) { - switch (n.kind) { - case 69: - case 169: { - var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384) !== 0; - } - case 170: { - var index = n.argumentExpression; - var symbol = findSymbol(n.expression); - 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) & 16384) !== 0; - } + return false; + } + function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { + var node = skipParenthesizedNodes(expr); + if (node.kind !== 69 && node.kind !== 170 && node.kind !== 171) { + error(expr, invalidReferenceMessage); + return false; + } + var links = getNodeLinks(node); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol) { + if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { + if (node.kind === 69 && !(symbol.flags & 3)) { + error(expr, invalidReferenceMessage); return false; } - case 175: - return isConstVariableReference(n.expression); - default: + if (isReferenceToReadonlyEntity(node, symbol) || isReferenceThroughNamespaceImport(node)) { + error(expr, constantVariableMessage); return false; + } } } - if (!isReferenceOrErrorExpression(n)) { - error(n, invalidReferenceMessage); - return false; - } - if (isConstVariableReference(n)) { - error(n, constantVariableMessage); - return false; + else if (node.kind === 171) { + if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { + error(expr, constantVariableMessage); + return false; + } } return true; } @@ -19381,7 +19968,7 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.parserContextFlags & 8)) { + if (!(node.flags & 33554432)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -19397,7 +19984,7 @@ var ts; case 35: case 36: case 50: - if (someConstituentTypeHasKind(operandType, 16777216)) { + if (maybeTypeOfKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; @@ -19407,7 +19994,7 @@ var ts; case 42: 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } @@ -19417,40 +20004,48 @@ var ts; var operandType = checkExpression(node.operand); 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } - function someConstituentTypeHasKind(type, kind) { + function maybeTypeOfKind(type, kind) { if (type.flags & kind) { return true; } if (type.flags & 49152) { var types = type.types; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var current = types_10[_i]; - if (current.flags & kind) { + var t = types_10[_i]; + if (maybeTypeOfKind(t, kind)) { return true; } } - return false; } return false; } - function allConstituentTypesHaveKind(type, kind) { + function isTypeOfKind(type, kind) { if (type.flags & kind) { return true; } - if (type.flags & 49152) { + if (type.flags & 16384) { var types = type.types; for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var current = types_11[_i]; - if (!(current.flags & kind)) { + var t = types_11[_i]; + if (!isTypeOfKind(t, kind)) { return false; } } return true; } + if (type.flags & 32768) { + var types = type.types; + for (var _a = 0, types_12 = types; _a < types_12.length; _a++) { + var t = types_12[_a]; + if (isTypeOfKind(t, kind)) { + return true; + } + } + } return false; } function isConstEnumObjectType(type) { @@ -19460,7 +20055,7 @@ var ts; return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 16777726)) { + if (isTypeOfKind(leftType, 16777726)) { error(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))) { @@ -19481,22 +20076,22 @@ var ts; var properties = node.properties; for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var p = properties_3[_i]; - if (p.kind === 248 || p.kind === 249) { - var name_13 = p.name; - if (name_13.kind === 137) { - checkComputedPropertyName(name_13); + if (p.kind === 249 || p.kind === 250) { + var name_12 = p.name; + if (name_12.kind === 138) { + checkComputedPropertyName(name_12); } - if (isComputedNonLiteralName(name_13)) { + if (isComputedNonLiteralName(name_12)) { continue; } - var text = getTextOfPropertyName(name_13); + var text = getTextOfPropertyName(name_12); var type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, text) || isNumericLiteralName(text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - if (p.kind === 249) { + if (p.kind === 250) { checkDestructuringAssignment(p, type); } else { @@ -19504,7 +20099,7 @@ var ts; } } else { - error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); + error(name_12, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_12)); } } else { @@ -19518,8 +20113,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 190) { - if (e.kind !== 188) { + if (e.kind !== 191) { + if (e.kind !== 189) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -19544,7 +20139,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 184 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 185 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -19558,7 +20153,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 249) { + if (exprOrAssignment.kind === 250) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); @@ -19568,21 +20163,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 184 && target.operatorToken.kind === 56) { + if (target.kind === 185 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 168) { + if (target.kind === 169) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 167) { + if (target.kind === 168) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) { checkTypeAssignableTo(sourceType, targetType, target, undefined); } return sourceType; @@ -19592,7 +20187,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 168 || left.kind === 167)) { + if (operator === 56 && (left.kind === 169 || left.kind === 168)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -19645,11 +20240,11 @@ var ts; if (rightType.flags & (32 | 64)) rightType = leftType; var resultType; - if (allConstituentTypesHaveKind(leftType, 132) && allConstituentTypesHaveKind(rightType, 132)) { + if (isTypeOfKind(leftType, 132) && isTypeOfKind(rightType, 132)) { resultType = numberType; } else { - if (allConstituentTypesHaveKind(leftType, 258) || allConstituentTypesHaveKind(rightType, 258)) { + if (isTypeOfKind(leftType, 258) || isTypeOfKind(rightType, 258)) { resultType = stringType; } else if (isTypeAny(leftType) || isTypeAny(rightType)) { @@ -19678,7 +20273,7 @@ var ts; case 31: case 32: case 33: - if (someConstituentTypeHasKind(leftType, 258) && someConstituentTypeHasKind(rightType, 258)) { + if (maybeTypeOfKind(leftType, 258) && maybeTypeOfKind(rightType, 258)) { return booleanType; } if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { @@ -19700,8 +20295,8 @@ var ts; return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : - someConstituentTypeHasKind(rightType, 16777216) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 16777216) ? left : + maybeTypeOfKind(rightType, 16777216) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -19726,7 +20321,7 @@ var ts; } function checkAssignmentOperator(valueType) { if (produceDiagnostics && operator >= 56 && operator <= 68) { - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); if (ok) { checkTypeAssignableTo(valueType, leftType, left, undefined); } @@ -19753,7 +20348,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.parserContextFlags & 2) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8388608) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -19816,14 +20411,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 137) { + if (node.name.kind === 138) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 137) { + if (node.name.kind === 138) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -19846,7 +20441,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 136) { + if (node.kind === 137) { type = checkQualifiedName(node); } else { @@ -19854,9 +20449,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 169 && node.parent.expression === node) || - (node.parent.kind === 170 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 136) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 170 && node.parent.expression === node) || + (node.parent.kind === 171 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 137) && 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); } @@ -19882,7 +20477,7 @@ var ts; return booleanType; case 8: return checkNumericLiteral(node); - case 186: + case 187: return checkTemplateExpression(node); case 9: return checkStringLiteralExpression(node); @@ -19890,58 +20485,58 @@ var ts; return stringType; case 10: return globalRegExpType; - case 167: - return checkArrayLiteral(node, contextualMapper); case 168: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 169: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 170: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 171: + return checkIndexedAccess(node); case 172: - return checkCallExpression(node); case 173: - return checkTaggedTemplateExpression(node); - case 175: - return checkExpression(node.expression, contextualMapper); - case 189: - return checkClassExpression(node); - case 176: - case 177: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 179: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 174: - case 192: - return checkAssertion(node); - case 178: - return checkDeleteExpression(node); - case 180: - return checkVoidExpression(node); - case 181: - return checkAwaitExpression(node); - case 182: - return checkPrefixUnaryExpression(node); - case 183: - return checkPostfixUnaryExpression(node); - case 184: - return checkBinaryExpression(node, contextualMapper); - case 185: - return checkConditionalExpression(node, contextualMapper); - case 188: - return checkSpreadElementExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 176: + return checkExpression(node.expression, contextualMapper); case 190: + return checkClassExpression(node); + case 177: + case 178: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 180: + return checkTypeOfExpression(node); + case 175: + case 193: + return checkAssertion(node); + case 179: + return checkDeleteExpression(node); + case 181: + return checkVoidExpression(node); + case 182: + return checkAwaitExpression(node); + case 183: + return checkPrefixUnaryExpression(node); + case 184: + return checkPostfixUnaryExpression(node); + case 185: + return checkBinaryExpression(node, contextualMapper); + case 186: + return checkConditionalExpression(node, contextualMapper); + case 189: + return checkSpreadElementExpression(node, contextualMapper); + case 191: return undefinedType; - case 187: + case 188: return checkYieldExpression(node); - case 243: + case 244: return checkJsxExpression(node); - case 236: - return checkJsxElement(node); case 237: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 238: + return checkJsxSelfClosingElement(node); + case 239: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -19960,9 +20555,9 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 56) { + if (node.flags & 28) { func = ts.getContainingFunction(node); - if (!(func.kind === 145 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 146 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -19977,9 +20572,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 144 || - node.kind === 216 || - node.kind === 176; + return node.kind === 145 || + node.kind === 217 || + node.kind === 177; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -19996,18 +20591,18 @@ var ts; function checkTypePredicate(node) { var parent = getTypePredicateParent(node); if (!parent) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; } - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(parent)); - if (!returnType || !(returnType.flags & 134217728)) { + var typePredicate = getSignatureFromDeclaration(parent).typePredicate; + if (!typePredicate) { return; } var parameterName = node.parameterName; - if (parameterName.kind === 162) { + if (ts.isThisTypePredicate(typePredicate)) { getTypeFromThisTypeNode(parameterName); } else { - var typePredicate = returnType.predicate; if (typePredicate.parameterIndex >= 0) { if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); @@ -20019,10 +20614,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_14 = _a[_i].name; - if ((name_14.kind === 164 || - name_14.kind === 165) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, parameterName, typePredicate.parameterName)) { + var name_13 = _a[_i].name; + if (ts.isBindingPattern(name_13) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_13, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -20035,55 +20629,57 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 178: + case 149: + case 217: case 177: - case 148: - case 216: - case 176: - case 153: + case 154: + case 145: case 144: - case 143: - var parent_6 = node.parent; - if (node === parent_6.type) { - return parent_6; + var parent_7 = node.parent; + if (node === parent_7.type) { + return parent_7; } } } function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var name_15 = _a[_i].name; - if (name_15.kind === 69 && - name_15.text === predicateVariableName) { + var name_14 = _a[_i].name; + if (name_14.kind === 69 && + name_14.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_15.kind === 165 || - name_15.kind === 164) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_15, predicateVariableNode, predicateVariableName)) { + else if (name_14.kind === 166 || + name_14.kind === 165) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 150) { + if (node.kind === 151) { checkGrammarIndexSignature(node); } - else if (node.kind === 153 || node.kind === 216 || node.kind === 154 || - node.kind === 148 || node.kind === 145 || - node.kind === 149) { + else if (node.kind === 154 || node.kind === 217 || node.kind === 155 || + node.kind === 149 || node.kind === 146 || + node.kind === 150) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); - checkSourceElement(node.type); + if (node.type) { + checkSourceElement(node.type); + } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 149: + case 150: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 148: + case 149: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -20100,12 +20696,14 @@ var ts; checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } + else if (ts.isAsyncFunctionLike(node)) { + checkAsyncFunctionReturnType(node); + } } } - checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 218) { + if (node.kind === 219) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -20120,7 +20718,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 130: + case 131: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -20128,7 +20726,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 128: + case 129: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -20167,14 +20765,11 @@ var ts; if (!produceDiagnostics) { return; } - function isSuperCallExpression(n) { - return n.kind === 171 && n.expression.kind === 95; - } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { - if (isSuperCallExpression(n)) { + if (ts.isSuperCallExpression(n)) { return true; } else if (ts.isFunctionLike(n)) { @@ -20189,32 +20784,31 @@ var ts; if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 176 && n.kind !== 216) { + else if (n.kind !== 177 && n.kind !== 217) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 142 && - !(n.flags & 64) && + return n.kind === 143 && + !(n.flags & 32) && !!n.initializer; } 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 classExtendsNull = classDeclarationExtendsNull(containingClassDecl); + var superCall = getSuperCallInConstructor(node); + if (superCall) { + if (classExtendsNull) { + error(superCall, 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 & (8 | 16 | 32); }); + ts.forEach(node.parameters, function (p) { return p.flags & (4 | 8 | 16); }); if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 198 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 199 && ts.isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -20225,12 +20819,9 @@ var ts; 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(superCallStatement.expression); - } } } - else if (baseConstructorType !== nullType) { + else if (!classExtendsNull) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -20240,9 +20831,9 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 146) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288)) { - if (node.flags & 1048576) { + if (node.kind === 147) { + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 32768)) { + if (node.flags & 65536) { if (compilerOptions.noImplicitReturns) { error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -20252,16 +20843,19 @@ var ts; } } } - if (node.name.kind === 137) { + if (node.name.kind === 138) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 146 ? 147 : 146; + var otherKind = node.kind === 147 ? 148 : 147; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 56) !== (otherAccessor.flags & 56))) { + if (((node.flags & 28) !== (otherAccessor.flags & 28))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } + if (((node.flags & 128) !== (otherAccessor.flags & 128))) { + error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + } var currentAccessorType = getAnnotatedAccessorType(node); var otherAccessorType = getAnnotatedAccessorType(otherAccessor); if (currentAccessorType && otherAccessorType) { @@ -20273,7 +20867,7 @@ var ts; } getTypeOfAccessors(getSymbolOfNode(node)); } - if (node.parent.kind !== 168) { + if (node.parent.kind !== 169) { checkSourceElement(node.body); } else { @@ -20340,49 +20934,18 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 16) && ts.isInAmbientContext(node); - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { - if (!produceDiagnostics) { - return; - } - var signature = getSignatureFromDeclaration(signatureDeclarationNode); - if (!signature.hasStringLiterals) { - return; - } - if (ts.nodeIsPresent(signatureDeclarationNode.body)) { - error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); - return; - } - var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 218) { - ts.Debug.assert(signatureDeclarationNode.kind === 148 || signatureDeclarationNode.kind === 149); - var signatureKind = signatureDeclarationNode.kind === 148 ? 0 : 1; - var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - var containingType = getDeclaredTypeOfSymbol(containingSymbol); - signaturesToCheck = getSignaturesOfType(containingType, signatureKind); - } - else { - signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); - } - for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { - var otherSignature = signaturesToCheck_1[_i]; - if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature, false)) { - return; - } - } - error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); + return (node.flags & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 218 && - n.parent.kind !== 217 && - n.parent.kind !== 189 && + if (n.parent.kind !== 219 && + n.parent.kind !== 218 && + n.parent.kind !== 190 && ts.isInAmbientContext(n)) { - if (!(flags & 4)) { - flags |= 2; + if (!(flags & 2)) { + flags |= 1; } - flags |= 4; + flags |= 2; } return flags & flagsToCheck; } @@ -20400,17 +20963,17 @@ var ts; var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 2) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); + if (deviation & 1) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 4) { + else if (deviation & 2) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (16 | 32)) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); + else if (deviation & (8 | 16)) { + error(o.name || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } else if (deviation & 128) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); } @@ -20426,7 +20989,7 @@ var ts; }); } } - var flagsToCheck = 2 | 4 | 16 | 32 | 128; + var flagsToCheck = 1 | 2 | 8 | 16 | 128; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -20454,10 +21017,10 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 144 || node.kind === 143) && - (node.flags & 64) !== (subsequentNode.flags & 64); + var reportError = (node.kind === 145 || node.kind === 144) && + (node.flags & 32) !== (subsequentNode.flags & 32); if (reportError) { - var diagnostic = node.flags & 64 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = node.flags & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -20488,11 +21051,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 218 || node.parent.kind === 156 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 219 || node.parent.kind === 157 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 216 || node.kind === 144 || node.kind === 143 || node.kind === 145) { + if (node.kind === 217 || node.kind === 145 || node.kind === 144 || node.kind === 146) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -20543,13 +21106,11 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - if (!bodySignature.hasStringLiterals) { - for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { - var signature = signatures_3[_a]; - if (!signature.hasStringLiterals && !isImplementationCompatibleWithOverload(bodySignature, signature)) { - error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); - break; - } + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; + if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { + error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); + break; } } } @@ -20575,8 +21136,8 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 | 512); - if (effectiveDeclarationFlags & 2) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 512); + if (effectiveDeclarationFlags & 1) { if (effectiveDeclarationFlags & 512) { defaultExportedDeclarationSpaces |= declarationSpaces; } @@ -20605,16 +21166,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 218: + case 219: return 2097152; - case 221: + case 222: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 217: - case 220: + case 218: + case 221: return 2097152 | 1048576; - case 224: + case 225: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -20704,7 +21265,23 @@ var ts; } } } + function checkCorrectPromiseType(returnType, location) { + if (returnType === unknownType) { + return unknownType; + } + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType === emptyGenericType + || globalPromiseType === getTargetType(returnType)) { + return checkAwaitedType(returnType, location, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + error(location, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + return unknownType; + } function checkAsyncFunctionReturnType(node) { + if (languageVersion >= 2) { + var returnType = getTypeFromTypeNode(node.type); + return checkCorrectPromiseType(returnType, node.type); + } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType === emptyObjectType) { return unknownType; @@ -20745,22 +21322,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 217: + case 218: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 139: + case 140: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 142: + case 143: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 144: - case 146: + case 145: case 147: + case 148: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -20769,9 +21346,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 152) { + if (node && node.kind === 153) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 152 ? 793056 : 1536; + var meaning = root.parent.kind === 153 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -20801,24 +21378,24 @@ var ts; return; } if (!compilerOptions.experimentalDecorators) { - error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 217: + case 218: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 144: - case 146: + case 145: case 147: + case 148: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 142: - case 139: + case 143: + case 140: checkTypeAnnotationAsExpression(node); break; } @@ -20831,13 +21408,14 @@ var ts; checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function checkFunctionOrMethodDeclaration(node) { checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 137) { + if (node.name && node.name.kind === 138) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -20869,7 +21447,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 195) { + if (node.kind === 196) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -20888,19 +21466,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 142 || - node.kind === 141 || + if (node.kind === 143 || + node.kind === 142 || + node.kind === 145 || node.kind === 144 || - node.kind === 143 || - node.kind === 146 || - node.kind === 147) { + node.kind === 147 || + node.kind === 148) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 139 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 140 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -20948,19 +21526,31 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 221 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 222 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 251 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 252 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } - function checkVarDeclaredNamesNotShadowed(node) { - if ((ts.getCombinedNodeFlags(node) & 24576) !== 0 || ts.isParameterDeclaration(node)) { + function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 214 && !node.initializer) { + if (node.kind === 222 && ts.getModuleInstanceState(node) !== 1) { + return; + } + var parent = getDeclarationContainer(node); + if (parent.kind === 252 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2097152) { + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); + } + } + function checkVarDeclaredNamesNotShadowed(node) { + if ((ts.getCombinedNodeFlags(node) & 3072) !== 0 || ts.isParameterDeclaration(node)) { + return; + } + if (node.kind === 215 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -20969,26 +21559,26 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 215); - var container = varDeclList.parent.kind === 196 && varDeclList.parent.parent + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 3072) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 216); + var container = varDeclList.parent.kind === 197 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 195 && ts.isFunctionLike(container.parent) || + (container.kind === 196 && ts.isFunctionLike(container.parent) || + container.kind === 223 || container.kind === 222 || - container.kind === 221 || - container.kind === 251); + container.kind === 252); if (!namesShareScope) { - var name_16 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_16, name_16); + 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); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 139) { + if (ts.getRootDeclaration(node).kind !== 140) { return; } var func = ts.getContainingFunction(node); @@ -20997,7 +21587,7 @@ var ts; if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 139) { + if (referencedSymbol.valueDeclaration.kind === 140) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -21017,26 +21607,26 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 137) { + if (node.name.kind === 138) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 166) { - if (node.propertyName && node.propertyName.kind === 137) { + if (node.kind === 167) { + if (node.propertyName && node.propertyName.kind === 138) { checkComputedPropertyName(node.propertyName); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 139 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 140 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 203) { + if (node.initializer && node.parent.parent.kind !== 204) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -21045,7 +21635,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = getTypeOfVariableOrParameterOrProperty(symbol); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 203) { + if (node.initializer && node.parent.parent.kind !== 204) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -21059,14 +21649,15 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 142 && node.kind !== 141) { + if (node.kind !== 143 && node.kind !== 142) { checkExportsOnMergedDeclarations(node); - if (node.kind === 214 || node.kind === 166) { + if (node.kind === 215 || node.kind === 167) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function checkVariableDeclaration(node) { @@ -21082,7 +21673,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 168) { + if (node.modifiers && node.parent.kind === 169) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -21101,7 +21692,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 197) { + if (node.thenStatement.kind === 198) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -21118,12 +21709,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 215) { + if (node.initializer && node.initializer.kind === 216) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -21138,18 +21729,18 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 167 || varExpr.kind === 168) { + if (varExpr.kind === 168 || varExpr.kind === 169) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); if (iteratedType) { checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); } @@ -21159,7 +21750,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { 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); @@ -21169,14 +21760,14 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 167 || varExpr.kind === 168) { + if (varExpr.kind === 168 || varExpr.kind === 169) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); } } var rightType = checkExpression(node.expression); @@ -21336,8 +21927,8 @@ var ts; function checkBreakOrContinueStatement(node) { checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } - function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 146 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 147))); + function isGetAccessorWithAnnotatedSetAccessor(node) { + return !!(node.kind === 147 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 148))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -21355,15 +21946,15 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 147) { + if (func.kind === 148) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 145) { + else if (func.kind === 146) { if (!checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || returnType.flags & 134217728) { + else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -21380,7 +21971,7 @@ var ts; } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 8) { + if (node.flags & 33554432) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -21392,9 +21983,9 @@ var ts; var firstDefaultClause; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); - var expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, 258); + var expressionTypeIsStringLike = maybeTypeOfKind(expressionType, 258); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 245 && !hasDuplicateDefaultClause) { + if (clause.kind === 246 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21406,10 +21997,10 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 244) { + if (produceDiagnostics && clause.kind === 245) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); - var expressionTypeIsAssignableToCaseType = (expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, 258)) || + var expressionTypeIsAssignableToCaseType = (expressionTypeIsStringLike && maybeTypeOfKind(caseType, 258)) || isTypeAssignableTo(expressionType, caseType); if (!expressionTypeIsAssignableToCaseType) { checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); @@ -21425,7 +22016,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 210 && current.label.text === node.label.text) { + if (current.kind === 211 && 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; @@ -21492,7 +22083,7 @@ var ts; var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(member.flags & 64) && ts.hasDynamicName(member)) { + if (!(member.flags & 32) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); @@ -21519,7 +22110,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 137 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 138 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -21563,6 +22154,23 @@ var ts; } } } + function checkTypeParameterListsIdentical(node, symbol) { + if (symbol.declarations.length === 1) { + return; + } + var firstDecl; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 218 || declaration.kind === 219) { + if (!firstDecl) { + firstDecl = declaration; + } + else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + } + } + } + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -21585,6 +22193,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } checkTypeParameters(node.typeParameters); checkExportsOnMergedDeclarations(node); @@ -21592,12 +22201,14 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); + checkTypeParameterListsIdentical(node, symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); @@ -21646,6 +22257,18 @@ var ts; checkTypeForDuplicateIndexSignatures(node); } } + function checkBaseTypeAccessibility(type, node) { + var signatures = getSignaturesOfType(type, 1); + if (signatures.length) { + var declaration = signatures[0].declaration; + if (declaration && declaration.flags & 8) { + var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); + if (!isNodeWithinClass(node, typeClassDeclaration)) { + error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, node.expression.text); + } + } + } + } function getTargetSymbol(s) { return s.flags & 16777216 ? getSymbolLinks(s).target : s; } @@ -21667,7 +22290,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(derivedClassDecl.flags & 128))) { - if (derivedClassDecl.kind === 189) { + if (derivedClassDecl.kind === 190) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -21677,10 +22300,10 @@ var ts; } else { var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 16) || (derivedDeclarationFlags & 16)) { + if ((baseDeclarationFlags & 8) || (derivedDeclarationFlags & 8)) { continue; } - if ((baseDeclarationFlags & 64) !== (derivedDeclarationFlags & 64)) { + if ((baseDeclarationFlags & 32) !== (derivedDeclarationFlags & 32)) { continue; } if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { @@ -21711,7 +22334,7 @@ var ts; } } function isAccessor(kind) { - return kind === 146 || kind === 147; + return kind === 147 || kind === 148; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -21777,12 +22400,8 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 218); - if (symbol.declarations.length > 1) { - if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); - } - } + checkTypeParameterListsIdentical(node, symbol); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 219); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -21813,7 +22432,7 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 8192)) { + if (!(nodeLinks.flags & 16384)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; @@ -21846,7 +22465,7 @@ var ts; autoValue++; } } - nodeLinks.flags |= 8192; + nodeLinks.flags |= 16384; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { var reportError = true; @@ -21875,7 +22494,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 182: + case 183: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -21886,7 +22505,7 @@ var ts; case 50: return ~value_1; } return undefined; - case 184: + case 185: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -21911,11 +22530,11 @@ var ts; return undefined; case 8: return +e.text; - case 175: + case 176: return evalConstant(e.expression); case 69: + case 171: case 170: - case 169: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -21926,7 +22545,7 @@ var ts; } else { var expression; - if (e.kind === 170) { + if (e.kind === 171) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -21943,7 +22562,7 @@ var ts; if (current.kind === 69) { break; } - else if (current.kind === 169) { + else if (current.kind === 170) { current = current.expression; } else { @@ -21984,6 +22603,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumIsConst = ts.isConst(node); @@ -22002,7 +22622,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 220) { + if (declaration.kind !== 221) { return false; } var enumDeclaration = declaration; @@ -22025,8 +22645,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 217 || - (declaration.kind === 216 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 218 || + (declaration.kind === 217 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -22067,6 +22687,7 @@ var ts; } checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); if (symbol.flags & 512 @@ -22082,7 +22703,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, 217); + var mergedClass = ts.getDeclarationOfKind(symbol, 218); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -22120,40 +22741,40 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 196: + case 197: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 230: case 231: + case 232: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 224: + case 225: if (node.moduleReference.kind !== 9) { error(node.name, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); break; } - case 225: + case 226: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 166: - case 214: - var name_17 = node.name; - if (ts.isBindingPattern(name_17)) { - for (var _b = 0, _c = name_17.elements; _b < _c.length; _b++) { + case 167: + case 215: + var name_16 = node.name; + if (ts.isBindingPattern(name_16)) { + for (var _b = 0, _c = name_16.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 217: - case 220: - case 216: case 218: case 221: + case 217: case 219: + case 222: + case 220: var symbol = getSymbolOfNode(node); if (symbol) { var reportError = !(symbol.flags & 33554432); @@ -22174,10 +22795,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 136) { + if (node.kind === 137) { node = node.left; } - else if (node.kind === 169) { + else if (node.kind === 170) { node = node.expression; } else { @@ -22193,9 +22814,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 222 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 251 && !inAmbientExternalModule) { - error(moduleName, node.kind === 231 ? + var inAmbientExternalModule = node.parent.kind === 223 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 252 && !inAmbientExternalModule) { + error(moduleName, node.kind === 232 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -22216,7 +22837,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 233 ? + var message = node.kind === 234 ? 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)); @@ -22226,13 +22847,14 @@ var ts; function checkImportBinding(node) { checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); } function checkImportDeclaration(node) { if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -22242,7 +22864,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227) { + if (importClause.namedBindings.kind === 228) { checkImportBinding(importClause.namedBindings); } else { @@ -22259,7 +22881,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 2) { + if (node.flags & 1) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -22277,7 +22899,7 @@ var ts; } } else { - if (modulekind === 5 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } @@ -22287,27 +22909,27 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 222 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 251 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 223 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 252 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } else { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol && moduleSymbol.exports["export="]) { + if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } } } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 251 && node.parent.kind !== 222 && node.parent.kind !== 221) { + if (node.parent.kind !== 252 && node.parent.kind !== 223 && node.parent.kind !== 222) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -22316,7 +22938,7 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; var symbol = resolveName(exportedName, exportedName.text, 107455 | 793056 | 1536 | 8388608, undefined, undefined); - if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); } else { @@ -22328,12 +22950,12 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 251 ? node.parent : node.parent.parent; - if (container.kind === 221 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 252 ? node.parent : node.parent.parent; + if (container.kind === 222 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69) { @@ -22344,10 +22966,10 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === 5) { + if (modulekind === ts.ModuleKind.ES6) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (modulekind === 4) { + else if (modulekind === ts.ModuleKind.System) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } @@ -22377,11 +22999,17 @@ var ts; continue; } var _a = exports[id], declarations = _a.declarations, flags = _a.flags; - if (!(flags & (1536 | 64 | 384)) && (flags & 524288 ? declarations.length - 1 : declarations.length) > 1) { - var exportedDeclarations = ts.filter(declarations, isNotOverload); - if (exportedDeclarations.length > 1) { - for (var _i = 0, exportedDeclarations_1 = exportedDeclarations; _i < exportedDeclarations_1.length; _i++) { - var declaration = exportedDeclarations_1[_i]; + if (flags & (1536 | 64 | 384)) { + continue; + } + var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); + if (flags & 524288 && exportedDeclarationsCount <= 2) { + continue; + } + if (exportedDeclarationsCount > 1) { + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } @@ -22390,7 +23018,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 216 || !!declaration.body; + return declaration.kind !== 217 || !!declaration.body; } } function checkSourceElement(node) { @@ -22400,118 +23028,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 221: - case 217: + case 222: case 218: - case 216: + case 219: + case 217: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 138: - return checkTypeParameter(node); case 139: + return checkTypeParameter(node); + case 140: return checkParameter(node); + case 143: case 142: - case 141: return checkPropertyDeclaration(node); - case 153: case 154: - case 148: + case 155: case 149: - return checkSignatureDeclaration(node); case 150: return checkSignatureDeclaration(node); - case 144: - case 143: - return checkMethodDeclaration(node); - case 145: - return checkConstructorDeclaration(node); - case 146: - case 147: - return checkAccessorDeclaration(node); - case 152: - return checkTypeReferenceNode(node); case 151: + return checkSignatureDeclaration(node); + case 145: + case 144: + return checkMethodDeclaration(node); + case 146: + return checkConstructorDeclaration(node); + case 147: + case 148: + return checkAccessorDeclaration(node); + case 153: + return checkTypeReferenceNode(node); + case 152: return checkTypePredicate(node); - case 155: - return checkTypeQuery(node); case 156: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 157: - return checkArrayType(node); + return checkTypeLiteral(node); case 158: - return checkTupleType(node); + return checkArrayType(node); case 159: + return checkTupleType(node); case 160: - return checkUnionOrIntersectionType(node); case 161: + return checkUnionOrIntersectionType(node); + case 162: return checkSourceElement(node.type); - case 216: - return checkFunctionDeclaration(node); - case 195: - case 222: - return checkBlock(node); - case 196: - return checkVariableStatement(node); - case 198: - return checkExpressionStatement(node); - case 199: - return checkIfStatement(node); - case 200: - return checkDoStatement(node); - case 201: - return checkWhileStatement(node); - case 202: - return checkForStatement(node); - case 203: - return checkForInStatement(node); - case 204: - return checkForOfStatement(node); - case 205: - case 206: - return checkBreakOrContinueStatement(node); - case 207: - return checkReturnStatement(node); - case 208: - return checkWithStatement(node); - case 209: - return checkSwitchStatement(node); - case 210: - return checkLabeledStatement(node); - case 211: - return checkThrowStatement(node); - case 212: - return checkTryStatement(node); - case 214: - return checkVariableDeclaration(node); - case 166: - return checkBindingElement(node); case 217: - return checkClassDeclaration(node); - case 218: - return checkInterfaceDeclaration(node); - case 219: - return checkTypeAliasDeclaration(node); - case 220: - return checkEnumDeclaration(node); - case 221: - return checkModuleDeclaration(node); - case 225: - return checkImportDeclaration(node); - case 224: - return checkImportEqualsDeclaration(node); - case 231: - return checkExportDeclaration(node); - case 230: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 196: + case 223: + return checkBlock(node); case 197: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 199: + return checkExpressionStatement(node); + case 200: + return checkIfStatement(node); + case 201: + return checkDoStatement(node); + case 202: + return checkWhileStatement(node); + case 203: + return checkForStatement(node); + case 204: + return checkForInStatement(node); + case 205: + return checkForOfStatement(node); + case 206: + case 207: + return checkBreakOrContinueStatement(node); + case 208: + return checkReturnStatement(node); + case 209: + return checkWithStatement(node); + case 210: + return checkSwitchStatement(node); + case 211: + return checkLabeledStatement(node); + case 212: + return checkThrowStatement(node); case 213: + return checkTryStatement(node); + case 215: + return checkVariableDeclaration(node); + case 167: + return checkBindingElement(node); + case 218: + return checkClassDeclaration(node); + case 219: + return checkInterfaceDeclaration(node); + case 220: + return checkTypeAliasDeclaration(node); + case 221: + return checkEnumDeclaration(node); + case 222: + return checkModuleDeclaration(node); + case 226: + return checkImportDeclaration(node); + case 225: + return checkImportEqualsDeclaration(node); + case 232: + return checkExportDeclaration(node); + case 231: + return checkExportAssignment(node); + case 198: checkGrammarStatementInAmbientContext(node); return; - case 234: + case 214: + checkGrammarStatementInAmbientContext(node); + return; + case 235: return checkMissingDeclaration(node); } } @@ -22524,17 +23152,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 176: case 177: + case 178: + case 145: case 144: - case 143: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 146: case 147: + case 148: checkAccessorDeferred(node); break; - case 189: + case 190: checkClassExpressionDeferred(node); break; } @@ -22599,7 +23227,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 208 && node.parent.statement === node) { + if (node.parent.kind === 209 && node.parent.statement === node) { return true; } node = node.parent; @@ -22621,28 +23249,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 251: + case 252: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 221: + case 222: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 220: + case 221: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 189: + case 190: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 217: case 218: - if (!(memberFlags & 64)) { + case 219: + if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 176: + case 177: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -22681,36 +23309,47 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 138: - case 217: + case 139: case 218: case 219: case 220: + case 221: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 136) { + while (node.parent && node.parent.kind === 137) { node = node.parent; } - return node.parent && node.parent.kind === 152; + return node.parent && node.parent.kind === 153; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 169) { + while (node.parent && node.parent.kind === 170) { node = node.parent; } - return node.parent && node.parent.kind === 191; + return node.parent && node.parent.kind === 192; + } + function isNodeWithinClass(node, classDeclaration) { + while (true) { + node = ts.getContainingClass(node); + if (!node) { + return false; + } + if (node === classDeclaration) { + return true; + } + } } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 136) { + while (nodeOnRightSide.parent.kind === 137) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224) { + if (nodeOnRightSide.parent.kind === 225) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 230) { + if (nodeOnRightSide.parent.kind === 231) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -22722,10 +23361,22 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 230) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 170) { + var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case 1: + case 3: + return getSymbolOfNode(entityName.parent); + case 4: + case 2: + return getSymbolOfNode(entityName.parent.parent); + default: + } + } + if (entityName.parent.kind === 231) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 169) { + if (entityName.kind !== 170) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -22735,7 +23386,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 191) { + if (entityName.parent.kind === 192) { meaning = 793056; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -22747,10 +23398,10 @@ var ts; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 238) || - (entityName.parent.kind === 237) || - (entityName.parent.kind === 240)) { - return getJsxElementTagSymbol(entityName.parent); + else if ((entityName.parent.kind === 239) || + (entityName.parent.kind === 238) || + (entityName.parent.kind === 241)) { + return getJsxTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { @@ -22760,14 +23411,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 169) { + else if (entityName.kind === 170) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 136) { + else if (entityName.kind === 137) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -22776,14 +23427,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 152 ? 793056 : 1536; + var meaning = entityName.parent.kind === 153 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 241) { + else if (entityName.parent.kind === 242) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 151) { + if (entityName.parent.kind === 152) { return resolveEntityName(entityName, 1); } return undefined; @@ -22797,12 +23448,12 @@ var ts; } if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 230 + return node.parent.kind === 231 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 166 && - node.parent.parent.kind === 164 && + else if (node.parent.kind === 167 && + node.parent.parent.kind === 165 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -22813,30 +23464,30 @@ var ts; } switch (node.kind) { case 69: - case 169: - case 136: + case 170: + case 137: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97: case 95: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 162: + case 163: return getTypeFromTypeNode(node).symbol; case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 145) { + if (constructorDeclaration && constructorDeclaration.kind === 146) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 225 || node.parent.kind === 231) && + ((node.parent.kind === 226 || node.parent.kind === 232) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 170 && node.parent.argumentExpression === node) { + if (node.parent.kind === 171 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -22850,7 +23501,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 249) { + if (location && location.kind === 250) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -22907,7 +23558,7 @@ var ts; } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 64 + return node.flags & 32 ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -22926,9 +23577,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols = []; - var name_18 = symbol.name; + var name_17 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_18); + var symbol = getPropertyOfType(t, name_17); if (symbol) { symbols.push(symbol); } @@ -22951,7 +23602,7 @@ var ts; if (!moduleSymbol) { return true; } - var hasExportAssignment = getExportAssignmentSymbol(moduleSymbol) !== undefined; + var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol); moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); var symbolLinks = getSymbolLinks(moduleSymbol); if (symbolLinks.exportsSomeValue === undefined) { @@ -22977,11 +23628,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 251) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 252) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 221 || n.kind === 220) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 222 || n.kind === 221) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -22992,54 +23643,56 @@ var ts; var symbol = getReferencedValueSymbol(node); return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; } - function isStatementWithLocals(node) { - switch (node.kind) { - case 195: - case 223: - case 202: - case 203: - case 204: - return true; - } - return false; - } - function isNestedRedeclarationSymbol(symbol) { + function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418) { var links = getSymbolLinks(symbol); - if (links.isNestedRedeclaration === undefined) { + if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); + if (ts.isStatementWithLocals(container)) { + var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); + if (!!resolveName(container.parent, symbol.name, 107455, undefined, undefined)) { + links.isDeclarationWithCollidingName = true; + } + else if (nodeLinks_1.flags & 131072) { + var isDeclaredInLoop = nodeLinks_1.flags & 262144; + var inLoopInitializer = ts.isIterationStatement(container, false); + var inLoopBodyBlock = container.kind === 196 && ts.isIterationStatement(container.parent, false); + links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); + } + else { + links.isDeclarationWithCollidingName = false; + } + } } - return links.isNestedRedeclaration; + return links.isDeclarationWithCollidingName; } return false; } - function getReferencedNestedRedeclaration(node) { + function getReferencedDeclarationWithCollidingName(node) { var symbol = getReferencedValueSymbol(node); - return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + return symbol && isSymbolOfDeclarationWithCollidingName(symbol) ? symbol.valueDeclaration : undefined; } - function isNestedRedeclaration(node) { - return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + function isDeclarationWithCollidingName(node) { + return isSymbolOfDeclarationWithCollidingName(getSymbolOfNode(node)); } function isValueAliasDeclaration(node) { switch (node.kind) { - case 224: - case 226: + case 225: case 227: - case 229: - case 233: + case 228: + case 230: + case 234: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 231: + case 232: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 230: + case 231: return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 251 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 252 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -23087,7 +23740,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 250) { + if (node.kind === 251) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -23118,22 +23771,22 @@ var ts; else if (type.flags & 1) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (allConstituentTypesHaveKind(type, 16)) { + else if (isTypeOfKind(type, 16)) { return ts.TypeReferenceSerializationKind.VoidType; } - else if (allConstituentTypesHaveKind(type, 8)) { + else if (isTypeOfKind(type, 8)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (allConstituentTypesHaveKind(type, 132)) { + else if (isTypeOfKind(type, 132)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (allConstituentTypesHaveKind(type, 258)) { + else if (isTypeOfKind(type, 258)) { return ts.TypeReferenceSerializationKind.StringLikeType; } - else if (allConstituentTypesHaveKind(type, 8192)) { + else if (isTypeOfKind(type, 8192)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 16777216)) { + else if (isTypeOfKind(type, 16777216)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -23177,8 +23830,8 @@ var ts; return { getReferencedExportContainer: getReferencedExportContainer, getReferencedImportDeclaration: getReferencedImportDeclaration, - getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, - isNestedRedeclaration: isNestedRedeclaration, + getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName, + isDeclarationWithCollidingName: isDeclarationWithCollidingName, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -23207,7 +23860,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 251); + return ts.getDeclarationOfKind(moduleSymbol, 252); } function initializeTypeChecker() { ts.forEach(host.getSourceFiles(), function (file) { @@ -23218,7 +23871,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } - if (file.moduleAugmentations) { + if (file.moduleAugmentations.length) { (augmentations || (augmentations = [])).push(file.moduleAugmentations); } }); @@ -23272,6 +23925,9 @@ var ts; globalIterableIteratorType = emptyGenericType; } anyArrayType = createArrayType(anyType); + var symbol = getGlobalSymbol("ReadonlyArray", 793056, undefined); + globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); + anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); @@ -23295,14 +23951,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 144 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 145 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 146 || node.kind === 147) { + else if (node.kind === 147 || node.kind === 148) { 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); @@ -23312,38 +23968,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 146: case 147: - case 145: - case 142: - case 141: - case 144: + case 148: + case 146: case 143: - case 150: - case 221: + case 142: + case 145: + case 144: + case 151: + case 222: + case 226: case 225: - case 224: + case 232: case 231: - case 230: - case 139: - break; - case 216: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && - node.parent.kind !== 222 && node.parent.kind !== 251) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 140: break; case 217: - case 218: - case 196: - case 219: - if (node.modifiers && node.parent.kind !== 222 && node.parent.kind !== 251) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 223 && node.parent.kind !== 252) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 218: + case 219: + case 197: case 220: + if (node.modifiers && node.parent.kind !== 223 && node.parent.kind !== 252) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 221: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && - node.parent.kind !== 222 && node.parent.kind !== 251) { + node.parent.kind !== 223 && node.parent.kind !== 252) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23353,42 +24009,48 @@ var ts; if (!node.modifiers) { return; } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync, lastReadonly; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; + if (modifier.kind !== 127) { + if (node.kind === 142 || node.kind === 144) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); + } + if (node.kind === 151) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); + } + } switch (modifier.kind) { case 74: - if (node.kind !== 220 && node.parent.kind === 217) { + if (node.kind !== 221 && node.parent.kind === 218) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); } break; case 112: case 111: case 110: - var text = void 0; - if (modifier.kind === 112) { - text = "public"; - } - else if (modifier.kind === 111) { - text = "protected"; + var text = visibilityToString(ts.modifierToFlag(modifier.kind)); + if (modifier.kind === 111) { lastProtected = modifier; } - else { - text = "private"; + else if (modifier.kind === 110) { lastPrivate = modifier; } - if (flags & 56) { + if (flags & 28) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 64) { + else if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } + else if (flags & 64) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); + } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 222 || node.parent.kind === 251) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + else if (node.parent.kind === 223 || node.parent.kind === 252) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { if (modifier.kind === 110) { @@ -23401,29 +24063,42 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113: - if (flags & 64) { + if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } + else if (flags & 64) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); + } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 222 || node.parent.kind === 251) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + else if (node.parent.kind === 223 || node.parent.kind === 252) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 139) { + else if (node.kind === 140) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 64; + flags |= 32; lastStatic = modifier; break; + case 127: + if (flags & 64) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); + } + else if (node.kind !== 143 && node.kind !== 142 && node.kind !== 151) { + return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); + } + flags |= 64; + lastReadonly = modifier; + break; case 82: - if (flags & 2) { + if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 4) { + else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } else if (flags & 128) { @@ -23432,48 +24107,51 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 217) { + else if (node.parent.kind === 218) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 139) { + else if (node.kind === 140) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 2; + flags |= 1; break; case 122: - if (flags & 4) { + if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 217) { + else if (node.parent.kind === 218) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 139) { + else if (node.kind === 140) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 222) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 223) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 4; + flags |= 2; lastDeclare = modifier; break; case 115: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 217) { - if (node.kind !== 144) { - return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + if (node.kind !== 218) { + if (node.kind !== 145 && + node.kind !== 143 && + node.kind !== 147 && + node.kind !== 148) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 217 && node.parent.flags & 128)) { + if (!(node.parent.kind === 218 && node.parent.flags & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 64) { + if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 16) { + if (flags & 8) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } @@ -23483,10 +24161,10 @@ var ts; if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 4 || ts.isInAmbientContext(node.parent)) { + 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 === 139) { + else if (node.kind === 140) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -23494,28 +24172,25 @@ var ts; break; } } - if (node.kind === 145) { - if (flags & 64) { + if (node.kind === 146) { + if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 32) { - return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & 16) { - return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } else if (flags & 256) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } + else if (flags & 64) { + return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly"); + } return; } - else if ((node.kind === 225 || node.kind === 224) && flags & 4) { + else if ((node.kind === 226 || node.kind === 225) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 139 && (flags & 56) && ts.isBindingPattern(node.name)) { + else if (node.kind === 140 && (flags & 28) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 256) { @@ -23527,10 +24202,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 144: - case 216: - case 176: + case 145: + case 217: case 177: + case 178: if (!node.asteriskToken) { return false; } @@ -23595,7 +24270,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 177) { + if (node.kind === 178) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -23618,7 +24293,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 1022) { + if (parameter.flags & 959) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -23630,20 +24305,15 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { + if (parameter.type.kind !== 131 && parameter.type.kind !== 129) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); } } - function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 1022) { - grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } function checkGrammarIndexSignature(node) { - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node); } function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { if (typeArguments && typeArguments.length === 0) { @@ -23662,7 +24332,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { var arg = args_1[_i]; - if (arg.kind === 190) { + if (arg.kind === 191) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -23733,19 +24403,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 137) { + if (node.kind !== 138) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 184 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 185 && 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 === 216 || - node.kind === 176 || - node.kind === 144); + ts.Debug.assert(node.kind === 217 || + node.kind === 177 || + node.kind === 145); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -23766,61 +24436,61 @@ var ts; var seen = {}; var Property = 1; var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; + var SetAccessor = 4; + var GetOrSetAccessor = GetAccessor | SetAccessor; var _loop_1 = function(prop) { - var name_19 = prop.name; - if (prop.kind === 190 || - name_19.kind === 137) { - checkGrammarComputedPropertyName(name_19); + var name_18 = prop.name; + if (prop.kind === 191 || + name_18.kind === 138) { + checkGrammarComputedPropertyName(name_18); return "continue"; } - if (prop.kind === 249 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 250 && !inDestructuring && prop.objectAssignmentInitializer) { return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) }; } ts.forEach(prop.modifiers, function (mod) { - if (mod.kind !== 118 || prop.kind !== 144) { + if (mod.kind !== 118 || prop.kind !== 145) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } }); var currentKind = void 0; - if (prop.kind === 248 || prop.kind === 249) { + if (prop.kind === 249 || prop.kind === 250) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_19.kind === 8) { - checkGrammarNumericLiteral(name_19); + if (name_18.kind === 8) { + checkGrammarNumericLiteral(name_18); } currentKind = Property; } - else if (prop.kind === 144) { + else if (prop.kind === 145) { currentKind = Property; } - else if (prop.kind === 146) { + else if (prop.kind === 147) { currentKind = GetAccessor; } - else if (prop.kind === 147) { - currentKind = SetAccesor; + else if (prop.kind === 148) { + currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_19.text)) { - seen[name_19.text] = currentKind; + if (!ts.hasProperty(seen, name_18.text)) { + seen[name_18.text] = currentKind; } else { - var existingKind = seen[name_19.text]; + var existingKind = seen[name_18.text]; if (currentKind === Property && existingKind === Property) { return "continue"; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_19.text] = currentKind | existingKind; + seen[name_18.text] = currentKind | existingKind; } else { - return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; + return { value: grammarErrorOnNode(name_18, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; } } else { - return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; + return { value: grammarErrorOnNode(name_18, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; } } }; @@ -23835,19 +24505,19 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 242) { + if (attr.kind === 243) { continue; } var jsxAttr = attr; - var name_20 = jsxAttr.name; - if (!ts.hasProperty(seen, name_20.text)) { - seen[name_20.text] = true; + var name_19 = jsxAttr.name; + if (!ts.hasProperty(seen, name_19.text)) { + seen[name_19.text] = true; } else { - return grammarErrorOnNode(name_20, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_19, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 243 && !initializer.expression) { + if (initializer && initializer.kind === 244 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -23856,7 +24526,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 215) { + if (forInOrOfStatement.initializer.kind === 216) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -23864,20 +24534,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 203 + var diagnostic = forInOrOfStatement.kind === 204 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 203 + var diagnostic = forInOrOfStatement.kind === 204 ? 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 === 203 + var diagnostic = forInOrOfStatement.kind === 204 ? 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); @@ -23894,16 +24564,16 @@ var ts; else if (ts.isInAmbientContext(accessor)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); } - else if (accessor.body === undefined) { + else if (accessor.body === undefined && !(accessor.flags & 128)) { return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 146 && accessor.parameters.length) { + else if (kind === 147 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 147) { + else if (kind === 148) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -23915,7 +24585,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 1022) { + else if (parameter.flags & 959) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -23938,7 +24608,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 168) { + if (node.parent.kind === 169) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -23957,10 +24627,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 219) { 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 === 156) { + else if (node.parent.kind === 157) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -23971,9 +24641,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 210: + case 211: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 205 + var isMisplacedContinueLabel = node.kind === 206 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -23981,8 +24651,8 @@ var ts; return false; } break; - case 209: - if (node.kind === 206 && !node.label) { + case 210: + if (node.kind === 207 && !node.label) { return false; } break; @@ -23995,13 +24665,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 206 + var message = node.kind === 207 ? 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 === 206 + var message = node.kind === 207 ? 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); @@ -24013,7 +24683,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 === 165 || node.name.kind === 164) { + if (node.name.kind === 166 || node.name.kind === 165) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -24022,7 +24692,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 203 && node.parent.parent.kind !== 204) { + if (node.parent.parent.kind !== 204 && node.parent.parent.kind !== 205) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -24051,7 +24721,7 @@ var ts; var elements = name.elements; for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { var element = elements_2[_i]; - if (element.kind !== 190) { + if (element.kind !== 191) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -24068,15 +24738,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 199: case 200: case 201: - case 208: case 202: + case 209: case 203: case 204: + case 205: return false; - case 210: + case 211: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -24132,7 +24802,7 @@ var ts; return true; } } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 219) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -24140,7 +24810,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 156) { + else if (node.parent.kind === 157) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -24153,14 +24823,14 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 218 || - node.kind === 219 || + if (node.kind === 219 || + node.kind === 220 || + node.kind === 226 || node.kind === 225 || - node.kind === 224 || + node.kind === 232 || node.kind === 231 || - node.kind === 230 || - (node.flags & 4) || - (node.flags & (2 | 512))) { + (node.flags & 2) || + (node.flags & (1 | 512))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -24168,7 +24838,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 === 196) { + if (ts.isDeclaration(decl) || decl.kind === 197) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -24187,7 +24857,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 === 195 || node.parent.kind === 222 || node.parent.kind === 251) { + if (node.parent.kind === 196 || node.parent.kind === 223 || node.parent.kind === 252) { 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); @@ -24198,7 +24868,7 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 32768 && languageVersion >= 1) { + if (node.isOctalLiteral && languageVersion >= 1) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -24217,6 +24887,13 @@ var ts; var ts; (function (ts) { var nullSourceMapWriter; + var defaultLastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; function getNullSourceMapWriter() { if (nullSourceMapWriter === undefined) { nullSourceMapWriter = { @@ -24265,13 +24942,7 @@ var ts; currentSourceFile = undefined; sourceMapSourceIndex = -1; lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; + lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; lastEncodedNameIndex = 0; sourceMapData = { sourceMapFilePath: sourceMapFilePath, @@ -24324,7 +24995,7 @@ var ts; sourceMapData.sourceMapDecodedMappings.pop(); lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - undefined; + defaultLastEncodedSourceMapSpan; var sourceMapMappings = sourceMapData.sourceMapMappings; var lenthToSet = sourceMapMappings.length - 1; for (; lenthToSet >= 0; lenthToSet--) { @@ -24497,7 +25168,8 @@ var ts; var increaseIndent; var decreaseIndent; var writeTextOfNode; - var writer = createAndSetNewTextWriterWithSymbolWriter(); + var writer; + createAndSetNewTextWriterWithSymbolWriter(); var enclosingDeclaration; var resultHasExternalModuleIndicator; var currentText; @@ -24549,7 +25221,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 225); + ts.Debug.assert(aliasEmitInfo.node.kind === 226); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -24602,7 +25274,6 @@ var ts; writer.writeParameter = writer.write; writer.writeSymbol = writer.write; setWriter(writer); - return writer; } function setWriter(newWriter) { writer = newWriter; @@ -24616,10 +25287,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 214) { + if (declaration.kind === 215) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 228 || declaration.kind === 229 || declaration.kind === 226) { + else if (declaration.kind === 229 || declaration.kind === 230 || declaration.kind === 227) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -24630,7 +25301,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 225) { + if (moduleElementEmitInfo.node.kind === 226) { moduleElementEmitInfo.isVisible = true; } else { @@ -24638,12 +25309,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 221) { + if (nodeToCheck.kind === 222) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 221) { + if (nodeToCheck.kind === 222) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -24653,21 +25324,21 @@ var ts; }); setWriter(oldWriter); } - function handleSymbolAccessibilityError(symbolAccesibilityResult) { - if (symbolAccesibilityResult.accessibility === 0) { - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + function handleSymbolAccessibilityError(symbolAccessibilityResult) { + if (symbolAccessibilityResult.accessibility === 0) { + if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccessibilityResult.aliasesToMakeVisible); } } else { reportedDeclarationError = true; - var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccessibilityResult); if (errorInfo) { if (errorInfo.typeName) { - emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNodeFromSourceText(currentText, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNodeFromSourceText(currentText, errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } else { - emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } } } @@ -24741,40 +25412,40 @@ var ts; function emitType(type) { switch (type.kind) { case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: case 103: - case 162: case 163: + case 164: return writeTextOfNode(currentText, type); - case 191: + case 192: return emitExpressionWithTypeArguments(type); - case 152: - return emitTypeReference(type); - case 155: - return emitTypeQuery(type); - case 157: - return emitArrayType(type); - case 158: - return emitTupleType(type); - case 159: - return emitUnionType(type); - case 160: - return emitIntersectionType(type); - case 161: - return emitParenType(type); case 153: - case 154: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 156: + return emitTypeQuery(type); + case 158: + return emitArrayType(type); + case 159: + return emitTupleType(type); + case 160: + return emitUnionType(type); + case 161: + return emitIntersectionType(type); + case 162: + return emitParenType(type); + case 154: + case 155: + return emitSignatureDeclarationWithJsDocComments(type); + case 157: return emitTypeLiteral(type); case 69: return emitEntityName(type); - case 136: + case 137: return emitEntityName(type); - case 151: + case 152: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -24782,21 +25453,21 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 136 ? entityName.left : entityName.expression; - var right = entityName.kind === 136 ? entityName.right : entityName.name; + var left = entityName.kind === 137 ? entityName.left : entityName.expression; + var right = entityName.kind === 137 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 224 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 225 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 169); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 170); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -24870,9 +25541,9 @@ var ts; var count = 0; while (true) { count++; - var name_21 = baseName + "_" + count; - if (!ts.hasProperty(currentIdentifiers, name_21)) { - return name_21; + var name_20 = baseName + "_" + count; + if (!ts.hasProperty(currentIdentifiers, name_20)) { + return name_20; } } } @@ -24913,10 +25584,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 224 || - (node.parent.kind === 251 && isCurrentFileExternalModule)) { + else if (node.kind === 225 || + (node.parent.kind === 252 && isCurrentFileExternalModule)) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 251) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 252) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -24925,7 +25596,7 @@ var ts; }); } else { - if (node.kind === 225) { + if (node.kind === 226) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -24943,58 +25614,61 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 216: - return writeFunctionDeclaration(node); - case 196: - return writeVariableStatement(node); - case 218: - return writeInterfaceDeclaration(node); case 217: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 197: + return writeVariableStatement(node); case 219: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 218: + return writeClassDeclaration(node); case 220: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 221: + return writeEnumDeclaration(node); + case 222: return writeModuleDeclaration(node); - case 224: - return writeImportEqualsDeclaration(node); case 225: + return writeImportEqualsDeclaration(node); + case 226: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 251) { - if (node.flags & 2) { + if (node.parent.kind === 252) { + if (node.flags & 1) { write("export "); } if (node.flags & 512) { write("default "); } - else if (node.kind !== 218 && !noDeclare) { + else if (node.kind !== 219 && !noDeclare) { write("declare "); } } } - function emitClassMemberDeclarationFlags(node) { - if (node.flags & 16) { + function emitClassMemberDeclarationFlags(flags) { + if (flags & 8) { write("private "); } - else if (node.flags & 32) { + else if (flags & 16) { write("protected "); } - if (node.flags & 64) { + if (flags & 32) { write("static "); } - if (node.flags & 128) { + if (flags & 64) { + write("readonly "); + } + if (flags & 128) { write("abstract "); } } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); - if (node.flags & 2) { + if (node.flags & 1) { write("export "); } write("import "); @@ -25010,7 +25684,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult) { + function getImportEntityNameVisibilityError(symbolAccessibilityResult) { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -25020,7 +25694,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 227) { + if (namedBindings.kind === 228) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -25029,11 +25703,8 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 2)) { - return; - } emitJsDocComments(node); - if (node.flags & 2) { + if (node.flags & 1) { write("export "); } write("import "); @@ -25046,7 +25717,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 227) { + if (node.importClause.namedBindings.kind === 228) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -25063,13 +25734,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 221; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 222; var moduleSpecifier; - if (parent.kind === 224) { + if (parent.kind === 225) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 221) { + else if (parent.kind === 222) { moduleSpecifier = parent.name; } else { @@ -25124,7 +25795,7 @@ var ts; write("global "); } else { - if (node.flags & 65536) { + if (node.flags & 4096) { write("namespace "); } else { @@ -25137,7 +25808,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body.kind !== 222) { + while (node.body.kind !== 223) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -25166,7 +25837,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -25202,7 +25873,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 144 && (node.parent.flags & 16); + return node.parent.kind === 145 && (node.parent.flags & 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -25212,49 +25883,49 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 153 || - node.parent.kind === 154 || - (node.parent.parent && node.parent.parent.kind === 156)) { - ts.Debug.assert(node.parent.kind === 144 || - node.parent.kind === 143 || - node.parent.kind === 153 || + if (node.parent.kind === 154 || + node.parent.kind === 155 || + (node.parent.parent && node.parent.parent.kind === 157)) { + ts.Debug.assert(node.parent.kind === 145 || + node.parent.kind === 144 || node.parent.kind === 154 || - node.parent.kind === 148 || - node.parent.kind === 149); + node.parent.kind === 155 || + node.parent.kind === 149 || + node.parent.kind === 150); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 217: + case 218: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 218: + case 219: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 149: + case 150: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 148: + case 149: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 145: case 144: - case 143: - if (node.parent.flags & 64) { + if (node.parent.flags & 32) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 217) { + else if (node.parent.parent.kind === 218) { 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 216: + case 217: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -25285,9 +25956,9 @@ var ts; else if (!isImplementsList && node.expression.kind === 93) { write("null"); } - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + function getHeritageClauseVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 217) { + if (node.parent.parent.kind === 218) { 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; @@ -25307,7 +25978,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 56) { + if (param.flags & 28) { emitPropertyDeclaration(param); } }); @@ -25361,61 +26032,61 @@ var ts; return; } emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags); emitVariableDeclaration(node); write(";"); writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 214 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 215 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 142 || node.kind === 141) && ts.hasQuestionToken(node)) { + if ((node.kind === 143 || node.kind === 142) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 142 || node.kind === 141) && node.parent.kind === 156) { + if ((node.kind === 143 || node.kind === 142) && node.parent.kind === 157) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 16)) { + else if (!(node.flags & 8)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 214) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { + if (node.kind === 215) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 142 || node.kind === 141) { - if (node.flags & 64) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + else if (node.kind === 143 || node.kind === 142) { + if (node.flags & 32) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 217) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + else if (node.parent.kind === 218) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; } } } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, @@ -25426,15 +26097,15 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 190) { + if (element.kind !== 191) { elements.push(element); } } emitCommaList(elements, emitBindingElement); } function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getBindingElementTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: bindingElement, @@ -25486,13 +26157,13 @@ var ts; if (node === accessors.firstAccessor) { emitJsDocComments(accessors.getAccessor); emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags | (accessors.setAccessor ? 0 : 64)); writeTextOfNode(currentText, node.name); - if (!(node.flags & 16)) { + if (!(node.flags & 8)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 146 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 147 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -25505,23 +26176,23 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 146 + return accessor.kind === 147 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type : undefined; } } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 147) { - if (accessorWithTypeAnnotation.parent.flags & 64) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + if (accessorWithTypeAnnotation.kind === 148) { + if (accessorWithTypeAnnotation.parent.flags & 32) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; } @@ -25532,16 +26203,16 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 64) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + if (accessorWithTypeAnnotation.flags & 32) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; @@ -25560,17 +26231,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 216) { + if (node.kind === 217) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 144) { - emitClassMemberDeclarationFlags(node); + else if (node.kind === 145 || node.kind === 146) { + emitClassMemberDeclarationFlags(node.flags); } - if (node.kind === 216) { + if (node.kind === 217) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 145) { + else if (node.kind === 146) { write("constructor"); } else { @@ -25589,31 +26260,32 @@ var ts; function emitSignatureDeclaration(node) { var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; - if (node.kind === 149 || node.kind === 154) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 150) { + if (node.kind === 151) { + emitClassMemberDeclarationFlags(node.flags); write("["); } else { + if (node.kind === 150 || node.kind === 155) { + write("new "); + } + emitTypeParameters(node.typeParameters); write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 150) { + if (node.kind === 151) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 153 || node.kind === 154; - if (isFunctionTypeOrConstructorType || node.parent.kind === 156) { + var isFunctionTypeOrConstructorType = node.kind === 154 || node.kind === 155; + if (isFunctionTypeOrConstructorType || node.parent.kind === 157) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 145 && !(node.flags & 16)) { + else if (node.kind !== 146 && !(node.flags & 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -25621,49 +26293,49 @@ var ts; write(";"); writeLine(); } - function getReturnTypeVisibilityError(symbolAccesibilityResult) { + function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 149: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + case 150: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 148: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + case 149: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 150: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + case 151: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 145: case 144: - case 143: - if (node.flags & 64) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + if (node.flags & 32) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : 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 === 217) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + else if (node.parent.kind === 218) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 216: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + case 217: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -25693,62 +26365,62 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 153 || - node.parent.kind === 154 || - node.parent.parent.kind === 156) { + if (node.parent.kind === 154 || + node.parent.kind === 155 || + node.parent.parent.kind === 157) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 16)) { + else if (!(node.parent.flags & 8)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, typeName: node.name } : undefined; } - function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 145: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + case 146: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 149: - return symbolAccesibilityResult.errorModuleName ? + case 150: + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 148: - return symbolAccesibilityResult.errorModuleName ? + case 149: + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 145: case 144: - case 143: - if (node.parent.flags & 64) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + if (node.parent.flags & 32) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 217) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + else if (node.parent.parent.kind === 218) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? 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 216: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + case 217: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; @@ -25757,12 +26429,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 164) { + if (bindingPattern.kind === 165) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 165) { + else if (bindingPattern.kind === 166) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -25773,10 +26445,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 190) { + if (bindingElement.kind === 191) { write(" "); } - else if (bindingElement.kind === 166) { + else if (bindingElement.kind === 167) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -25798,39 +26470,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 216: - case 221: - case 224: - case 218: case 217: - case 219: - case 220: - return emitModuleElement(node, isModuleElementVisible(node)); - case 196: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 222: case 225: + case 219: + case 218: + case 220: + case 221: + return emitModuleElement(node, isModuleElementVisible(node)); + case 197: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 226: return emitModuleElement(node, !node.importClause); - case 231: + case 232: return emitExportDeclaration(node); + case 146: case 145: case 144: - case 143: return writeFunctionDeclaration(node); - case 149: - case 148: case 150: + case 149: + case 151: return emitSignatureDeclarationWithJsDocComments(node); - case 146: case 147: + case 148: return emitAccessorDeclaration(node); + case 143: case 142: - case 141: return emitPropertyDeclaration(node); - case 250: - return emitEnumMemberDeclaration(node); - case 230: - return emitExportAssignment(node); case 251: + return emitEnumMemberDeclaration(node); + case 231: + return emitExportAssignment(node); + case 252: return emitSourceFile(node); } } @@ -26157,7 +26829,7 @@ var ts; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new P(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.call(thisArg, _arguments)).next());\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -26226,9 +26898,11 @@ var ts; var isEs6Module; var isCurrentFileExternalModule; var exportFunctionForFile; + var contextObjectForFile; var generatedNameSet; var nodeToGeneratedName; var computedPropertyNamesToGeneratedNames; + var decoratedClassAliases; var convertedLoopState; var extendsEmitted; var decorateEmitted; @@ -26247,19 +26921,19 @@ var ts; var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; var setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer) { }; var moduleEmitDelegates = (_a = {}, - _a[5] = emitES6Module, - _a[2] = emitAMDModule, - _a[4] = emitSystemModule, - _a[3] = emitUMDModule, - _a[1] = emitCommonJSModule, + _a[ts.ModuleKind.ES6] = emitES6Module, + _a[ts.ModuleKind.AMD] = emitAMDModule, + _a[ts.ModuleKind.System] = emitSystemModule, + _a[ts.ModuleKind.UMD] = emitUMDModule, + _a[ts.ModuleKind.CommonJS] = emitCommonJSModule, _a ); var bundleEmitDelegates = (_b = {}, - _b[5] = function () { }, - _b[2] = emitAMDModule, - _b[4] = emitSystemModule, - _b[3] = function () { }, - _b[1] = function () { }, + _b[ts.ModuleKind.ES6] = function () { }, + _b[ts.ModuleKind.AMD] = emitAMDModule, + _b[ts.ModuleKind.System] = emitSystemModule, + _b[ts.ModuleKind.UMD] = function () { }, + _b[ts.ModuleKind.CommonJS] = function () { }, _b ); return doEmit; @@ -26267,6 +26941,7 @@ var ts; sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); generatedNameSet = {}; nodeToGeneratedName = []; + decoratedClassAliases = []; isOwnFileEmit = !isBundledEmit; if (isBundledEmit && modulekind) { ts.forEach(sourceFiles, emitEmitHelpers); @@ -26284,8 +26959,10 @@ var ts; currentText = undefined; currentLineMap = undefined; exportFunctionForFile = undefined; + contextObjectForFile = undefined; generatedNameSet = undefined; nodeToGeneratedName = undefined; + decoratedClassAliases = undefined; computedPropertyNamesToGeneratedNames = undefined; convertedLoopState = undefined; extendsEmitted = false; @@ -26310,6 +26987,7 @@ var ts; currentText = sourceFile.text; currentLineMap = ts.getLineStarts(sourceFile); exportFunctionForFile = undefined; + contextObjectForFile = undefined; isEs6Module = sourceFile.symbol && sourceFile.symbol.exports && !!sourceFile.symbol.exports["___esModule"]; renamedDependencies = sourceFile.renamedDependencies; currentFileIdentifiers = sourceFile.identifiers; @@ -26324,19 +27002,19 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_22 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_22)) { + var name_21 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_21)) { tempFlags |= flags; - return name_22; + return name_21; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_23 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_23)) { - return name_23; + var name_22 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_22)) { + return name_22; } } } @@ -26374,17 +27052,17 @@ var ts; switch (node.kind) { case 69: return makeUniqueName(node.text); + case 222: case 221: - case 220: return generateNameForModuleOrEnum(node); - case 225: - case 231: + case 226: + case 232: return generateNameForImportOrExportDeclaration(node); - case 216: case 217: - case 230: + case 218: + case 231: return generateNameForExportDefault(); - case 189: + case 190: return generateNameForClassExpression(); } } @@ -26624,10 +27302,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 186) { + if (node.template.kind === 187) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 184 + var needsParens = templateSpan.expression.kind === 185 && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -26651,7 +27329,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 175 + var needsParens = templateSpan.expression.kind !== 176 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -26671,11 +27349,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 171: case 172: - return parent.expression === template; case 173: - case 175: + return parent.expression === template; + case 174: + case 176: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -26683,7 +27361,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 184: + case 185: switch (expression.operatorToken.kind) { case 37: case 39: @@ -26695,8 +27373,8 @@ var ts; default: return -1; } - case 187: - case 185: + case 188: + case 186: return -1; default: return 1; @@ -26752,12 +27430,12 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 242; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 243; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; for (var i = 0; i < attrs.length; i++) { - if (attrs[i].kind === 242) { + if (attrs[i].kind === 243) { if (i === 0) { write("{}, "); } @@ -26771,7 +27449,7 @@ var ts; emit(attrs[i].expression); } else { - ts.Debug.assert(attrs[i].kind === 241); + ts.Debug.assert(attrs[i].kind === 242); if (haveOpenedObjectLiteral) { write(", "); } @@ -26801,32 +27479,52 @@ var ts; } } if (children) { - for (var i = 0; i < children.length; i++) { - if (children[i].kind === 243 && !(children[i].expression)) { - continue; - } - if (children[i].kind === 239) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); + var firstChild; + var multipleEmittableChildren = false; + for (var i = 0, n = children.length; i < n; i++) { + var jsxChild = children[i]; + if (isJsxChildEmittable(jsxChild)) { + if (!firstChild) { + write(", "); + firstChild = jsxChild; + } + else { + if (!multipleEmittableChildren) { + multipleEmittableChildren = true; + increaseIndent(); + writeLine(); + emit(firstChild); + } + write(", "); + writeLine(); + emit(jsxChild); } } + } + if (multipleEmittableChildren) { + decreaseIndent(); + } + else if (firstChild) { + if (firstChild.kind !== 237 && firstChild.kind !== 238) { + emit(firstChild); + } else { - write(", "); - emit(children[i]); + increaseIndent(); + writeLine(); + emit(firstChild); + writeLine(); + decreaseIndent(); } } } write(")"); emitTrailingComments(openingNode); } - if (node.kind === 236) { + if (node.kind === 237) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 237); + ts.Debug.assert(node.kind === 238); emitJsxElement(node); } } @@ -26848,11 +27546,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 242) { + if (attribs[i].kind === 243) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 241); + ts.Debug.assert(attribs[i].kind === 242); emitJsxAttribute(attribs[i]); } } @@ -26860,11 +27558,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 237)) { + if (node.attributes.length > 0 || (node.kind === 238)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 237) { + if (node.kind === 238) { write("/>"); } else { @@ -26883,20 +27581,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 236) { + if (node.kind === 237) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 237); + ts.Debug.assert(node.kind === 238); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 166); + ts.Debug.assert(node.kind !== 167); if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 137) { + else if (node.kind === 138) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -26927,75 +27625,71 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 167: - case 192: - case 184: - case 171: - case 244: - case 137: + case 168: + case 193: case 185: - case 140: - case 178: - case 200: - case 170: - case 230: - case 198: - case 191: - case 202: + case 172: + case 245: + case 138: + case 186: + case 141: + case 179: + case 201: + case 171: + case 231: + case 199: + case 192: case 203: case 204: - case 199: - case 240: - case 237: + case 205: + case 200: + case 241: case 238: - case 242: + case 239: case 243: - case 172: - case 175: - case 183: - case 182: - case 207: - case 249: - case 188: - case 209: + case 244: case 173: - case 193: - case 211: - case 174: - case 179: - case 180: - case 201: - case 208: - case 187: - return true; - case 166: - case 250: - case 139: - case 248: - case 142: - case 214: - return parent.initializer === node; - case 169: - return parent.expression === node; - case 177: case 176: + case 184: + case 183: + case 208: + case 250: + case 189: + case 210: + case 174: + case 194: + case 212: + case 175: + case 180: + case 181: + case 202: + case 209: + case 188: + return true; + case 167: + case 251: + case 140: + case 249: + case 143: + case 215: + return parent.initializer === node; + case 170: + return parent.expression === node; + case 178: + case 177: return parent.body === node; - case 224: + case 225: return parent.moduleReference === node; - case 136: + case 137: return parent.left === node; } return false; } function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048) { - write("_arguments"); - return; - } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 251) { - if (modulekind !== 5 && modulekind !== 4) { + if (container.kind === 252) { + if (modulekind !== ts.ModuleKind.ES6 && modulekind !== ts.ModuleKind.System) { write("exports."); } } @@ -27005,18 +27699,18 @@ var ts; } } else { - if (modulekind !== 5) { + if (modulekind !== ts.ModuleKind.ES6) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 226) { + if (declaration.kind === 227) { write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 229) { + else if (declaration.kind === 230) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_24 = declaration.propertyName || declaration.name; - var identifier = ts.getTextOfNodeFromSourceText(currentText, name_24); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getTextOfNodeFromSourceText(currentText, name_23); if (languageVersion === 0 && identifier === "default") { write("[\"default\"]"); } @@ -27028,13 +27722,23 @@ var ts; } } } - if (languageVersion !== 2) { - var declaration = resolver.getReferencedNestedRedeclaration(node); + if (languageVersion < 2) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration) { write(getGeneratedNameForNode(declaration.name)); return; } } + else if (resolver.getNodeCheckFlags(node) & 1048576) { + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration) { + var classAlias = decoratedClassAliases[ts.getNodeId(declaration)]; + if (classAlias !== undefined) { + write(classAlias); + return; + } + } + } } if (ts.nodeIsSynthesized(node)) { write(node.text); @@ -27043,15 +27747,15 @@ var ts; writeTextOfNode(currentText, node); } } - function isNameOfNestedRedeclaration(node) { + function isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node) { if (languageVersion < 2) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 166: - case 217: - case 220: - case 214: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_8 = node.parent; + switch (parent_8.kind) { + case 167: + case 218: + case 221: + case 215: + return parent_8.name === node && resolver.isDeclarationWithCollidingName(parent_8); } } return false; @@ -27059,8 +27763,8 @@ var ts; function emitIdentifier(node) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { - var name_25 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); - write(name_25); + var name_24 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_24); return; } } @@ -27070,7 +27774,7 @@ var ts; else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } - else if (isNameOfNestedRedeclaration(node)) { + else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { write(getGeneratedNameForNode(node)); } else if (ts.nodeIsSynthesized(node)) { @@ -27160,10 +27864,10 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 184 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 185 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 185 && node.parent.condition === node) { + else if (node.parent.kind === 186 && node.parent.condition === node) { return true; } return false; @@ -27171,11 +27875,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 69: - case 167: - case 169: + case 168: case 170: case 171: - case 175: + case 172: + case 176: return false; } return true; @@ -27192,17 +27896,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 188) { + if (e.kind === 189) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 167) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 168) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 188) { + while (i < length && elements[i].kind !== 189) { i++; } write("["); @@ -27225,7 +27929,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 188; + return node.kind === 189; } function emitArrayLiteral(node) { var elements = node.elements; @@ -27238,7 +27942,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 1024) !== 0, elements.hasTrailingComma, true); + emitListWithSpread(elements, true, node.multiLine, elements.hasTrailingComma, true); } } function emitObjectLiteralBody(node, numElements) { @@ -27253,7 +27957,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1, true); } else { - var multiLine = (node.flags & 1024) !== 0; + var multiLine = node.multiLine; if (!multiLine) { write(" "); } @@ -27272,7 +27976,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 1024) !== 0; + var multiLine = node.multiLine; var properties = node.properties; write("("); if (multiLine) { @@ -27286,7 +27990,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 146 || property.kind === 147) { + if (property.kind === 147 || property.kind === 148) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -27337,13 +28041,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 248) { + if (property.kind === 249) { emit(property.initializer); } - else if (property.kind === 249) { + else if (property.kind === 250) { emitExpressionIdentifier(property.name); } - else if (property.kind === 144) { + else if (property.kind === 145) { emitFunctionDeclaration(property); } else { @@ -27375,7 +28079,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 === 137) { + if (properties[i].name.kind === 138) { numInitialNonComputedProperties = i; break; } @@ -27389,35 +28093,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(184, startsOnNewLine); + var result = ts.createSynthesizedNode(185, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(169); + var result = ts.createSynthesizedNode(170); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(170); + var result = ts.createSynthesizedNode(171); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 174 || expr.kind === 192) { + while (expr.kind === 175 || expr.kind === 193) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 172 && + expr.kind !== 173 && expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(175); + var node = ts.createSynthesizedNode(176); node.expression = expr; return node; } @@ -27444,11 +28148,11 @@ var ts; } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 251; + return container && container.kind !== 252; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentText, node.name); - if (modulekind !== 5 || isNamespaceExportReference(node.name)) { + if (modulekind !== ts.ModuleKind.ES6 || isNamespaceExportReference(node.name)) { write(": "); emit(node.name); } @@ -27462,7 +28166,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 169 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 170 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -27473,7 +28177,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 169 || node.kind === 170 + return node.kind === 170 || node.kind === 171 ? resolver.getConstantValue(node) : undefined; } @@ -27496,6 +28200,14 @@ var ts; if (tryEmitConstantValue(node)) { return; } + if (languageVersion === 2 && + node.expression.kind === 95 && + isInAsyncMethodWithSuperInES6(node)) { + var name_25 = ts.createSynthesizedNode(9); + name_25.text = node.name.text; + emitSuperAccessInAsyncMethod(node.expression, name_25); + return; + } emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); var shouldEmitSpace = false; @@ -27553,7 +28265,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 136: + case 137: emitQualifiedNameAsExpression(node, useFallback); break; default: @@ -27565,16 +28277,22 @@ var ts; if (tryEmitConstantValue(node)) { return; } + if (languageVersion === 2 && + node.expression.kind === 95 && + isInAsyncMethodWithSuperInES6(node)) { + emitSuperAccessInAsyncMethod(node.expression, node.argumentExpression); + return; + } emit(node.expression); write("["); emit(node.argumentExpression); write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 188; }); + return ts.forEach(elements, function (e) { return e.kind === 189; }); } function skipParentheses(node) { - while (node.kind === 175 || node.kind === 174 || node.kind === 192) { + while (node.kind === 176 || node.kind === 175 || node.kind === 193) { node = node.expression; } return node; @@ -27595,12 +28313,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 169) { + if (expr.kind === 170) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 170) { + else if (expr.kind === 171) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -27629,23 +28347,42 @@ var ts; emitListWithSpread(node.arguments, false, false, false, true); write(")"); } + function isInAsyncMethodWithSuperInES6(node) { + if (languageVersion === 2) { + var container = ts.getSuperContainer(node, false); + if (container && resolver.getNodeCheckFlags(container) & (2048 | 4096)) { + return true; + } + } + return false; + } + function emitSuperAccessInAsyncMethod(superNode, argumentExpression) { + var container = ts.getSuperContainer(superNode, false); + var isSuperBinding = resolver.getNodeCheckFlags(container) & 4096; + write("_super("); + emit(argumentExpression); + write(isSuperBinding ? ").value" : ")"); + } function emitCallExpression(node) { if (languageVersion < 2 && hasSpreadElement(node.arguments)) { emitCallWithSpread(node); return; } + var expression = node.expression; var superCall = false; - if (node.expression.kind === 95) { - emitSuper(node.expression); + var isAsyncMethodWithSuper = false; + if (expression.kind === 95) { + emitSuper(expression); superCall = true; } else { - emit(node.expression); - superCall = node.expression.kind === 169 && node.expression.expression.kind === 95; + superCall = ts.isSuperPropertyOrElementAccess(expression); + isAsyncMethodWithSuper = superCall && isInAsyncMethodWithSuperInES6(node); + emit(expression); } - if (superCall && languageVersion < 2) { + if (superCall && (languageVersion < 2 || isAsyncMethodWithSuper)) { write(".call("); - emitThis(node.expression); + emitThis(expression); if (node.arguments.length) { write(", "); emitCommaList(node.arguments); @@ -27692,21 +28429,21 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 177) { - if (node.expression.kind === 174 || node.expression.kind === 192) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 178) { + if (node.expression.kind === 175 || node.expression.kind === 193) { var operand = node.expression.expression; - while (operand.kind === 174 || operand.kind === 192) { + while (operand.kind === 175 || operand.kind === 193) { operand = operand.expression; } - if (operand.kind !== 182 && + if (operand.kind !== 183 && + operand.kind !== 181 && operand.kind !== 180 && operand.kind !== 179 && - operand.kind !== 178 && - operand.kind !== 183 && - operand.kind !== 172 && - !(operand.kind === 171 && node.parent.kind === 172) && - !(operand.kind === 176 && node.parent.kind === 171) && - !(operand.kind === 8 && node.parent.kind === 169)) { + operand.kind !== 184 && + operand.kind !== 173 && + !(operand.kind === 172 && node.parent.kind === 173) && + !(operand.kind === 177 && node.parent.kind === 172) && + !(operand.kind === 8 && node.parent.kind === 170)) { emit(operand); return; } @@ -27735,7 +28472,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 214 || node.parent.kind === 166); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 215 || node.parent.kind === 167); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -27750,7 +28487,7 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 182) { + if (node.operand.kind === 183) { var operand = node.operand; if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { write(" "); @@ -27791,12 +28528,12 @@ var ts; if (!node || !isCurrentFileSystemExternalModule()) { return false; } - var current = node; + var current = ts.getRootDeclaration(node).parent; while (current) { - if (current.kind === 251) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 2) !== 0); + if (current.kind === 252) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 222) { + else if (ts.isDeclaration(current)) { return false; } else { @@ -27812,7 +28549,7 @@ var ts; if (ts.isElementAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(170, false); + synthesizedLHS = ts.createSynthesizedNode(171, false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); synthesizedLHS.expression = identifier; if (leftHandSideExpression.argumentExpression.kind !== 8 && @@ -27829,7 +28566,7 @@ var ts; else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(169, false); + synthesizedLHS = ts.createSynthesizedNode(170, false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); synthesizedLHS.expression = identifier; synthesizedLHS.dotToken = leftHandSideExpression.dotToken; @@ -27857,8 +28594,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 56 && - (node.left.kind === 168 || node.left.kind === 167)) { - emitDestructuring(node, node.parent.kind === 198); + (node.left.kind === 169 || node.left.kind === 168)) { + emitDestructuring(node, node.parent.kind === 199); } else { var exportChanged = node.operatorToken.kind >= 56 && @@ -27910,7 +28647,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 195) { + if (node && node.kind === 196) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -27924,12 +28661,12 @@ var ts; } emitToken(15, node.pos); increaseIndent(); - if (node.kind === 222) { - ts.Debug.assert(node.parent.kind === 221); + if (node.kind === 223) { + ts.Debug.assert(node.parent.kind === 222); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 222) { + if (node.kind === 223) { emitTempDeclarations(true); } decreaseIndent(); @@ -27937,7 +28674,7 @@ var ts; emitToken(16, node.statements.end); } function emitEmbeddedStatement(node) { - if (node.kind === 195) { + if (node.kind === 196) { write(" "); emit(node); } @@ -27949,7 +28686,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 177); + emitParenthesizedIf(node.expression, node.expression.kind === 178); write(";"); } function emitIfStatement(node) { @@ -27962,7 +28699,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(80, node.thenStatement.end); - if (node.elseStatement.kind === 199) { + if (node.elseStatement.kind === 200) { write(" "); emit(node.elseStatement); } @@ -27982,7 +28719,7 @@ var ts; else { emitNormalLoopBody(node, true); } - if (node.statement.kind === 195) { + if (node.statement.kind === 196) { write(" "); } else { @@ -28010,7 +28747,7 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 3072) === 0) { for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { var varDecl = _b[_a]; hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); @@ -28062,7 +28799,7 @@ var ts; } else { var loop = convertLoopBody(node); - if (node.parent.kind === 210) { + if (node.parent.kind === 211) { emitLabelAndColon(node.parent); } loopEmitter(node, loop); @@ -28072,34 +28809,30 @@ var ts; var functionName = makeUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 202: case 203: case 204: + case 205: var initializer = node.initializer; - if (initializer && initializer.kind === 215) { + if (initializer && initializer.kind === 216) { loopInitializer = node.initializer; } break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576)) { + var loopOutParameters; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3072)) { loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { var varDeclaration = _b[_a]; - collectNames(varDeclaration.name); + processVariableDeclaration(varDeclaration.name); } } - var bodyIsBlock = node.statement.kind === 195; + var bodyIsBlock = node.statement.kind === 196; var paramList = loopParameters ? loopParameters.join(", ") : ""; writeLine(); write("var " + functionName + " = function(" + paramList + ")"); - if (!bodyIsBlock) { - write(" {"); - writeLine(); - increaseIndent(); - } var convertedOuterLoopState = convertedLoopState; - convertedLoopState = {}; + convertedLoopState = { loopOutParameters: loopOutParameters }; if (convertedOuterLoopState) { if (convertedOuterLoopState.argumentsName) { convertedLoopState.argumentsName = convertedOuterLoopState.argumentsName; @@ -28111,14 +28844,32 @@ var ts; convertedLoopState.hoistedLocalVariables = convertedOuterLoopState.hoistedLocalVariables; } } - emitEmbeddedStatement(node.statement); - if (!bodyIsBlock) { - decreaseIndent(); - writeLine(); - write("}"); - } - write(";"); + write(" {"); writeLine(); + increaseIndent(); + if (bodyIsBlock) { + emitLines(node.statement.statements); + } + else { + emit(node.statement); + } + writeLine(); + copyLoopOutParameters(convertedLoopState, 1, true); + decreaseIndent(); + writeLine(); + write("};"); + writeLine(); + if (loopOutParameters) { + write("var "); + for (var i = 0; i < loopOutParameters.length; i++) { + if (i !== 0) { + write(", "); + } + write(loopOutParameters[i].outParamName); + } + write(";"); + writeLine(); + } if (convertedLoopState.argumentsName) { if (convertedOuterLoopState) { convertedOuterLoopState.argumentsName = convertedLoopState.argumentsName; @@ -28164,15 +28915,21 @@ var ts; var currentLoopState = convertedLoopState; convertedLoopState = convertedOuterLoopState; return { functionName: functionName, paramList: paramList, state: currentLoopState }; - function collectNames(name) { + function processVariableDeclaration(name) { if (name.kind === 69) { - var nameText = isNameOfNestedRedeclaration(name) ? getGeneratedNameForNode(name) : name.text; + var nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(name) + ? getGeneratedNameForNode(name) + : name.text; loopParameters.push(nameText); + if (resolver.getNodeCheckFlags(name.parent) & 2097152) { + var reassignedVariable = { originalName: name, outParamName: makeUniqueName("out_" + nameText) }; + (loopOutParameters || (loopOutParameters = [])).push(reassignedVariable); + } } else { for (var _a = 0, _b = name.elements; _a < _b.length; _a++) { var element = _b[_a]; - collectNames(element.name); + processVariableDeclaration(element.name); } } } @@ -28186,7 +28943,7 @@ var ts; if (emitAsEmbeddedStatement) { emitEmbeddedStatement(node.statement); } - else if (node.statement.kind === 195) { + else if (node.statement.kind === 196) { emitLines(node.statement.statements); } else { @@ -28197,6 +28954,28 @@ var ts; convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } } + function copyLoopOutParameters(state, copyDirection, emitAsStatements) { + if (state.loopOutParameters) { + for (var _a = 0, _b = state.loopOutParameters; _a < _b.length; _a++) { + var outParam = _b[_a]; + if (copyDirection === 0) { + emitIdentifier(outParam.originalName); + write(" = " + outParam.outParamName); + } + else { + write(outParam.outParamName + " = "); + emitIdentifier(outParam.originalName); + } + if (emitAsStatements) { + write(";"); + writeLine(); + } + else { + write(", "); + } + } + } + } function emitConvertedLoopCall(loop, emitAsBlock) { if (emitAsBlock) { write(" {"); @@ -28211,6 +28990,8 @@ var ts; write("var " + loopResult + " = "); } write(loop.functionName + "(" + loop.paramList + ");"); + writeLine(); + copyLoopOutParameters(loop.state, 0, true); if (!isSimpleLoop) { writeLine(); if (loop.state.nonLocalJumps & 8) { @@ -28220,7 +29001,7 @@ var ts; convertedLoopState.nonLocalJumps |= 8; } else { - write("return " + loopResult + ".value"); + write("return " + loopResult + ".value;"); } writeLine(); } @@ -28282,7 +29063,7 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 215) { + if (node.initializer && node.initializer.kind === 216) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList); if (startIsEmitted) { @@ -28308,7 +29089,7 @@ var ts; } } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 204) { + if (languageVersion < 2 && node.kind === 205) { emitLoop(node, emitDownLevelForOfStatementWorker); } else { @@ -28319,7 +29100,7 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList); @@ -28329,7 +29110,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 203) { + if (node.kind === 204) { write(" in "); } else { @@ -28382,7 +29163,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -28404,7 +29185,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); - if (node.initializer.kind === 167 || node.initializer.kind === 168) { + if (node.initializer.kind === 168 || node.initializer.kind === 169) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -28426,23 +29207,25 @@ var ts; } function emitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 206 ? 2 : 4; + var jump = node.kind === 207 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { + write("return "); + copyLoopOutParameters(convertedLoopState, 1, false); if (!node.label) { - if (node.kind === 206) { + if (node.kind === 207) { convertedLoopState.nonLocalJumps |= 2; - write("return \"break\";"); + write("\"break\";"); } else { convertedLoopState.nonLocalJumps |= 4; - write("return \"continue\";"); + write("\"continue\";"); } } else { var labelMarker; - if (node.kind === 206) { + if (node.kind === 207) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -28450,12 +29233,12 @@ var ts; labelMarker = "continue-" + node.label.text; setLabeledJump(convertedLoopState, false, node.label.text, labelMarker); } - write("return \"" + labelMarker + "\";"); + write("\"" + labelMarker + "\";"); } return; } } - emitToken(node.kind === 206 ? 70 : 75, node.pos); + emitToken(node.kind === 207 ? 70 : 75, node.pos); emitOptional(" ", node.label); write(";"); } @@ -28520,7 +29303,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap(currentLineMap, ts.skipTrivia(currentText, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 244) { + if (node.kind === 245) { write("case "); emit(node.expression); write(":"); @@ -28589,7 +29372,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 221); + } while (node && node.kind !== 222); return node; } function emitContainingModuleName(node) { @@ -28598,13 +29381,13 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 2) { + if (ts.getCombinedNodeFlags(node) & 1) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); write("."); } - else if (modulekind !== 5 && modulekind !== 4) { + else if (modulekind !== ts.ModuleKind.ES6 && modulekind !== ts.ModuleKind.System) { write("exports."); } } @@ -28614,14 +29397,14 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(180); + var result = ts.createSynthesizedNode(181); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 251) { - ts.Debug.assert(!!(node.flags & 512) || node.kind === 230); - if (modulekind === 1 || modulekind === 2 || modulekind === 3) { + if (node.parent.kind === 252) { + ts.Debug.assert(!!(node.flags & 512) || node.kind === 231); + if (modulekind === ts.ModuleKind.CommonJS || modulekind === ts.ModuleKind.AMD || modulekind === ts.ModuleKind.UMD) { if (!isEs6Module) { if (languageVersion !== 0) { write("Object.defineProperty(exports, \"__esModule\", { value: true });"); @@ -28636,10 +29419,10 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 2) { + if (node.flags & 1) { writeLine(); emitStart(node); - if (modulekind === 4 && node.parent === currentSourceFile) { + if (modulekind === ts.ModuleKind.System && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); if (node.flags & 512) { write("default"); @@ -28672,7 +29455,7 @@ var ts; } } function emitExportMemberAssignments(name) { - if (modulekind === 4) { + if (modulekind === ts.ModuleKind.System) { return; } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { @@ -28691,7 +29474,7 @@ var ts; } } function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(modulekind === 4); + ts.Debug.assert(modulekind === ts.ModuleKind.System); if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { return; } @@ -28715,7 +29498,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 214 || name.parent.kind === 166); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 215 || name.parent.kind === 167); emitStart(isFirstVariableDeclaration(nodeForSourceMap) ? nodeForSourceMap.parent : nodeForSourceMap); withTemporaryNoSourceMap(function () { if (isVariableDeclarationOrBindingElement) { @@ -28741,22 +29524,22 @@ var ts; return identifier; } function isFirstVariableDeclaration(root) { - return root.kind === 214 && - root.parent.kind === 215 && + return root.kind === 215 && + root.parent.kind === 216 && root.parent.declarations[0] === root; } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 214) { - var isExported = ts.getCombinedNodeFlags(root) & 2; + if (root.kind === 215) { + var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 139) { + else if (root.kind === 140) { canDefineTempVariablesInPlace = true; } - if (root.kind === 184) { + if (root.kind === 185) { emitAssignmentExpression(root); } else { @@ -28776,14 +29559,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue, sourceMapNode) { value = ensureIdentifier(value, true, sourceMapNode); - var equals = ts.createSynthesizedNode(184); + var equals = ts.createSynthesizedNode(185); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(185); + var cond = ts.createSynthesizedNode(186); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(53); cond.whenTrue = whenTrue; @@ -28798,20 +29581,20 @@ var ts; } function createPropertyAccessForDestructuringProperty(object, propName) { var index; - var nameIsComputed = propName.kind === 137; + var nameIsComputed = propName.kind === 138; if (nameIsComputed) { index = ensureIdentifier(propName.expression, false, propName); } else { index = ts.createSynthesizedNode(propName.kind); - index.text = propName.text; + index.text = ts.unescapeIdentifier(propName.text); } return !nameIsComputed && index.kind === 69 ? createPropertyAccessExpression(object, index) : createElementAccessExpression(object, index); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(171); + var call = ts.createSynthesizedNode(172); var sliceIdentifier = ts.createSynthesizedNode(69); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -28826,9 +29609,9 @@ var ts; } for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { var p = properties_5[_a]; - if (p.kind === 248 || p.kind === 249) { + if (p.kind === 249 || p.kind === 250) { var propName = p.name; - var target_1 = p.kind === 249 ? p : p.initializer || propName; + var target_1 = p.kind === 250 ? p : p.initializer || propName; emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName), p); } } @@ -28840,8 +29623,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 190) { - if (e.kind !== 188) { + if (e.kind !== 191) { + if (e.kind !== 189) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)), e); } else if (i === elements.length - 1) { @@ -28851,20 +29634,20 @@ var ts; } } function emitDestructuringAssignment(target, value, sourceMapNode) { - if (target.kind === 249) { + if (target.kind === 250) { if (target.objectAssignmentInitializer) { value = createDefaultValueCheck(value, target.objectAssignmentInitializer, sourceMapNode); } target = target.name; } - else if (target.kind === 184 && target.operatorToken.kind === 56) { + else if (target.kind === 185 && target.operatorToken.kind === 56) { value = createDefaultValueCheck(value, target.right, sourceMapNode); target = target.left; } - if (target.kind === 168) { + if (target.kind === 169) { emitObjectLiteralAssignment(target, value, sourceMapNode); } - else if (target.kind === 167) { + else if (target.kind === 168) { emitArrayLiteralAssignment(target, value, sourceMapNode); } else { @@ -28882,14 +29665,14 @@ var ts; emitDestructuringAssignment(target, value, ts.nodeIsSynthesized(root) ? target : root); } else { - if (root.parent.kind !== 175) { + if (root.parent.kind !== 176) { write("("); } value = ensureIdentifier(value, true, root); emitDestructuringAssignment(target, value, root); write(", "); emit(value); - if (root.parent.kind !== 175) { + if (root.parent.kind !== 176) { write(")"); } } @@ -28910,11 +29693,11 @@ var ts; } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 164) { + if (pattern.kind === 165) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 190) { + else if (element.kind !== 191) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -28942,12 +29725,23 @@ var ts; } else { var initializer = node.initializer; - if (!initializer && languageVersion < 2) { - var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 8192); - if (isLetDefinedInLoop && - node.parent.parent.kind !== 203 && - node.parent.parent.kind !== 204) { + if (!initializer && + languageVersion < 2 && + node.name.kind === 69) { + var container = ts.getEnclosingBlockScopeContainer(node); + var flags = resolver.getNodeCheckFlags(node); + var isCapturedInFunction = flags & 131072; + var isDeclaredInLoop = flags & 262144; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(container) || + (isCapturedInFunction && isDeclaredInLoop && container.kind === 196 && ts.isIterationStatement(container.parent, false)); + var emittedAsNestedLetDeclaration = ts.getCombinedNodeFlags(node) & 1024 && + !emittedAsTopLevel; + var emitExplicitInitializer = emittedAsNestedLetDeclaration && + container.kind !== 204 && + container.kind !== 205 && + (!resolver.isDeclarationWithCollidingName(node) || + (isDeclaredInLoop && !isCapturedInFunction && !ts.isIterationStatement(container, false))); + if (emitExplicitInitializer) { initializer = createVoidZero(); } } @@ -28965,7 +29759,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 190) { + if (node.kind === 191) { return; } var name = node.name; @@ -28976,20 +29770,14 @@ var ts; ts.forEach(name.elements, emitExportVariableAssignments); } } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 214 && node.parent.kind !== 166)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } function isES6ExportedDeclaration(node) { - return !!(node.flags & 2) && - modulekind === 5 && - node.parent.kind === 251; + return !!(node.flags & 1) && + modulekind === ts.ModuleKind.ES6 && + node.parent.kind === 252; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 2) { + if (node.flags & 1) { if (isES6ExportedDeclaration(node)) { write("export "); startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); @@ -29008,12 +29796,12 @@ var ts; write(";"); } } - if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } } function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 2)) { + if (!(node.flags & 1)) { return true; } if (isES6ExportedDeclaration(node)) { @@ -29134,12 +29922,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 146 ? "get " : "set "); + write(node.kind === 147 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 177 && languageVersion >= 2; + return node.kind === 178 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -29150,11 +29938,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 176) { + if (node.kind === 177) { return !!node.name; } - if (node.kind === 216) { - return !!node.name || modulekind !== 5; + if (node.kind === 217) { + return !!node.name || modulekind !== ts.ModuleKind.ES6; } } function emitFunctionDeclaration(node) { @@ -29162,12 +29950,12 @@ var ts; return emitCommentsOnNotEmittedNode(node); } var kind = node.kind, parent = node.parent; - if (kind !== 144 && - kind !== 143 && + if (kind !== 145 && + kind !== 144 && parent && - parent.kind !== 248 && - parent.kind !== 171 && - parent.kind !== 167) { + parent.kind !== 249 && + parent.kind !== 172 && + parent.kind !== 168) { emitLeadingComments(node); } emitStart(node); @@ -29188,11 +29976,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (modulekind !== 5 && kind === 216 && parent === currentSourceFile && node.name) { + if (modulekind !== ts.ModuleKind.ES6 && kind === 217 && parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (kind !== 144 && kind !== 143) { + if (kind !== 145 && kind !== 144) { emitTrailingComments(node); } } @@ -29224,12 +30012,20 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 177; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; + var isArrowFunction = node.kind === 178; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { write(" {"); increaseIndent(); writeLine(); + if (resolver.getNodeCheckFlags(node) & 4096) { + writeLines("\nconst _super = (function (geti, seti) {\n const cache = Object.create(null);\n return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });\n})(name => super[name], (name, value) => super[name] = value);"); + writeLine(); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + write("const _super = name => super[name];"); + writeLine(); + } write("return"); } write(" __awaiter(this"); @@ -29239,18 +30035,13 @@ var ts; else { write(", void 0, "); } - if (promiseConstructor) { + if (languageVersion >= 2 || !promiseConstructor) { + write("void 0"); + } + else { emitEntityNameAsExpression(promiseConstructor, false); } - else { - write("Promise"); - } - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } + write(", function* ()"); emitFunctionBody(node); write(")"); if (!isArrowFunction) { @@ -29265,7 +30056,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 195) { + if (node.body.kind === 196) { emitBlockFunctionBody(node, node.body); } else { @@ -29317,10 +30108,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 174) { + while (current.kind === 175) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 168); + emitParenthesizedIf(body, current.kind === 169); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -29387,23 +30178,22 @@ var ts; } emitToken(16, body.statements.end); } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 198) { - var expr = statement.expression; - if (expr && expr.kind === 171) { - var func = expr.expression; - if (func && func.kind === 95) { - return statement; - } - } - } + function getSuperCallAtGivenIndex(ctor, index) { + if (!ctor.body) { + return undefined; + } + var statements = ctor.body.statements; + if (!statements || index >= statements.length) { + return undefined; + } + var statement = statements[index]; + if (statement.kind === 199) { + return ts.isSuperCallExpression(statement.expression) ? statement : undefined; } } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 56) { + if (param.flags & 28) { writeLine(); emitStart(param); emitStart(param.name); @@ -29423,7 +30213,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 137) { + else if (memberName.kind === 138) { emitComputedPropertyName(memberName); } else { @@ -29435,7 +30225,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 142 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { + if (member.kind === 143 && isStatic === ((member.flags & 32) !== 0) && member.initializer) { properties.push(member); } } @@ -29456,7 +30246,7 @@ var ts; emit(receiver); } else { - if (property.flags & 64) { + if (property.flags & 32) { emitDeclarationName(node); } else { @@ -29475,11 +30265,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 194) { + if (member.kind === 195) { writeLine(); write(";"); } - else if (member.kind === 144 || node.kind === 143) { + else if (member.kind === 145 || node.kind === 144) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -29496,7 +30286,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 146 || member.kind === 147) { + else if (member.kind === 147 || member.kind === 148) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -29546,22 +30336,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 144 || node.kind === 143) && !member.body) { + if ((member.kind === 145 || node.kind === 144) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 144 || - member.kind === 146 || - member.kind === 147) { + else if (member.kind === 145 || + member.kind === 147 || + member.kind === 148) { writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 64) { + if (member.flags & 32) { write("static "); } - if (member.kind === 146) { + if (member.kind === 147) { write("get "); } - else if (member.kind === 147) { + else if (member.kind === 148) { write("set "); } if (member.asteriskToken) { @@ -29572,7 +30362,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 194) { + else if (member.kind === 195) { writeLine(); write(";"); } @@ -29597,10 +30387,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 145 && !member.body) { + if (member.kind === 146 && !member.body) { emitCommentsOnNotEmittedNode(member); } - if (member.kind === 142 && member.initializer && (member.flags & 64) === 0) { + if (member.kind === 143 && member.initializer && (member.flags & 32) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -29644,7 +30434,7 @@ var ts; emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); + superCall = getSuperCallAtGivenIndex(ctor, startIndex); if (superCall) { writeLine(); emit(superCall); @@ -29698,19 +30488,29 @@ var ts; else { emitClassLikeDeclarationForES6AndHigher(node); } - if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } } function emitClassLikeDeclarationForES6AndHigher(node) { + var decoratedClassAlias; var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 217) { + if (node.kind === 218) { if (thisNodeIsDecorated) { + if (resolver.getNodeCheckFlags(node) & 524288) { + decoratedClassAlias = ts.unescapeIdentifier(makeUniqueName(node.name ? node.name.text : "default")); + decoratedClassAliases[ts.getNodeId(node)] = decoratedClassAlias; + write("let " + decoratedClassAlias + ";"); + writeLine(); + } if (isES6ExportedDeclaration(node) && !(node.flags & 512)) { write("export "); } write("let "); emitDeclarationName(node); + if (decoratedClassAlias !== undefined) { + write(" = " + decoratedClassAlias); + } write(" = "); } else if (isES6ExportedDeclaration(node)) { @@ -29721,7 +30521,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 189; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 190; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -29731,7 +30531,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || (node.flags & 512 && (staticProperties.length > 0 || modulekind !== 5))) && !thisNodeIsDecorated) { + if (node.name || (node.flags & 512 && (staticProperties.length > 0 || modulekind !== ts.ModuleKind.ES6) && !thisNodeIsDecorated)) { write(" "); emitDeclarationName(node); } @@ -29749,6 +30549,7 @@ var ts; writeLine(); emitToken(16, node.members.end); if (thisNodeIsDecorated) { + decoratedClassAliases[ts.getNodeId(node)] = undefined; write(";"); } if (isClassExpressionWithStaticProperties) { @@ -29767,12 +30568,12 @@ var ts; else { writeLine(); emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); + emitDecoratorsOfClass(node, decoratedClassAlias); } - if (!(node.flags & 2)) { + if (!(node.flags & 1)) { return; } - if (modulekind !== 5) { + if (modulekind !== ts.ModuleKind.ES6) { emitExportMemberAssignment(node); } else { @@ -29784,7 +30585,7 @@ var ts; write(";"); } } - else if (node.parent.kind !== 251) { + else if (node.parent.kind !== 252) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -29796,7 +30597,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 217) { + if (node.kind === 218) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -29833,7 +30634,7 @@ var ts; emitMemberFunctionsForES5AndLower(node); emitPropertyDeclarations(node, getInitializedProperties(node, true)); writeLine(); - emitDecoratorsOfClass(node); + emitDecoratorsOfClass(node, undefined); writeLine(); emitToken(16, node.members.end, function () { write("return "); @@ -29856,26 +30657,26 @@ var ts; emit(baseTypeNode.expression); } write("))"); - if (node.kind === 217) { + if (node.kind === 218) { write(";"); } emitEnd(node); - if (node.kind === 217) { + if (node.kind === 218) { emitExportMemberAssignment(node); } } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 64)) { + if (!(member.flags & 32)) { write(".prototype"); } } - function emitDecoratorsOfClass(node) { + function emitDecoratorsOfClass(node, decoratedClassAlias) { emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 64); - emitDecoratorsOfConstructor(node); + emitDecoratorsOfMembers(node, 32); + emitDecoratorsOfConstructor(node, decoratedClassAlias); } - function emitDecoratorsOfConstructor(node) { + function emitDecoratorsOfConstructor(node, decoratedClassAlias) { var decorators = node.decorators; var constructor = ts.getFirstConstructorWithBody(node); var firstParameterDecorator = constructor && ts.forEach(constructor.parameters, function (parameter) { return parameter.decorators; }); @@ -29885,6 +30686,9 @@ var ts; writeLine(); emitStart(node.decorators || firstParameterDecorator); emitDeclarationName(node); + if (decoratedClassAlias !== undefined) { + write(" = " + decoratedClassAlias); + } write(" = __decorate(["); increaseIndent(); writeLine(); @@ -29906,7 +30710,7 @@ var ts; function emitDecoratorsOfMembers(node, staticFlag) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.flags & 64) !== staticFlag) { + if ((member.flags & 32) !== staticFlag) { continue; } if (!ts.nodeCanBeDecorated(member)) { @@ -29927,7 +30731,7 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 144) { + if (member.kind === 145) { functionLikeMember = member; } } @@ -29953,7 +30757,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); if (languageVersion > 0) { - if (member.kind !== 142) { + if (member.kind !== 143) { write(", null"); } else { @@ -29988,45 +30792,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 144: - case 146: + case 145: case 147: - case 142: + case 148: + case 143: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 144: + case 145: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 217: - case 144: - case 147: + case 218: + case 145: + case 148: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 217: + case 218: write("Function"); return; - case 142: + case 143: emitSerializedTypeNode(node.type); return; - case 139: - emitSerializedTypeNode(node.type); - return; - case 146: + case 140: emitSerializedTypeNode(node.type); return; case 147: + emitSerializedTypeNode(node.type); + return; + case 148: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -30042,40 +30846,40 @@ var ts; case 103: write("void 0"); return; - case 161: + case 162: emitSerializedTypeNode(node.type); return; - case 153: case 154: + case 155: write("Function"); return; - case 157: case 158: + case 159: write("Array"); return; - case 151: + case 152: case 120: write("Boolean"); return; - case 130: - case 163: + case 131: + case 164: write("String"); return; - case 128: + case 129: write("Number"); return; - case 131: + case 132: write("Symbol"); return; - case 152: + case 153: emitSerializedTypeReferenceNode(node); return; - case 155: case 156: - case 159: + case 157: case 160: + case 161: case 117: - case 162: + case 163: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -30139,7 +30943,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 217) { + if (node.kind === 218) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -30155,10 +30959,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 157) { + if (parameterType.kind === 158) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 152 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 153 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -30230,7 +31034,7 @@ var ts; } if (!shouldHoistDeclarationInSystemJsModule(node)) { var isES6ExportedEnum = isES6ExportedDeclaration(node); - if (!(node.flags & 2) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220))) { + if (!(node.flags & 1) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221))) { emitStart(node); if (isES6ExportedEnum) { write("export "); @@ -30259,7 +31063,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 2 && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { writeLine(); emitStart(node); write("var "); @@ -30269,8 +31073,8 @@ var ts; emitEnd(node); write(";"); } - if (modulekind !== 5 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 2)) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile) { + if (modulekind === ts.ModuleKind.System && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -30310,7 +31114,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 221) { + if (moduleDeclaration.body.kind === 222) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -30333,7 +31137,7 @@ var ts; var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { var isES6ExportedNamespace = isES6ExportedDeclaration(node); - if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221)) { + if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 222)) { emitStart(node); if (isES6ExportedNamespace) { write("export "); @@ -30351,7 +31155,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 222) { + if (node.body.kind === 223) { var saveConvertedLoopState = convertedLoopState; var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -30376,7 +31180,7 @@ var ts; emitToken(16, moduleBlock.statements.end); } write(")("); - if ((node.flags & 2) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -30386,7 +31190,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 2)) { + if (modulekind === ts.ModuleKind.System && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -30422,16 +31226,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 224) { + if (node.kind === 225) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 227) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 228) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 225 && node.importClause && !!node.importClause.name; + return node.kind === 226 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -30440,7 +31244,7 @@ var ts; ts.forEachChild(node, emitExportImportAssignments); } function emitImportDeclaration(node) { - if (modulekind !== 5) { + if (modulekind !== ts.ModuleKind.ES6) { return emitExternalImportDeclaration(node); } if (node.importClause) { @@ -30458,7 +31262,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 227) { + if (node.importClause.namedBindings.kind === 228) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -30484,21 +31288,24 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 224 && (node.flags & 2) !== 0; + var isExportedImport = node.kind === 225 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (modulekind !== 2) { + var varOrConst = (languageVersion <= 1) ? "var " : "const "; + if (modulekind !== ts.ModuleKind.AMD) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { - if (!isExportedImport) - write("var "); + if (!isExportedImport) { + write(varOrConst); + } + ; emitModuleMemberName(namespaceDeclaration); write(" = "); } else { - var isNakedImport = 225 && !node.importClause; + var isNakedImport = 226 && !node.importClause; if (!isNakedImport) { - write("var "); + write(varOrConst); write(getGeneratedNameForNode(node)); write(" = "); } @@ -30523,7 +31330,7 @@ var ts; write(";"); } else if (namespaceDeclaration && isDefaultImport(node)) { - write("var "); + write(varOrConst); emitModuleMemberName(namespaceDeclaration); write(" = "); write(getGeneratedNameForNode(node)); @@ -30550,7 +31357,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 2)) { + else if (!(node.flags & 1)) { write("var "); } } @@ -30572,13 +31379,13 @@ var ts; } } function emitExportDeclaration(node) { - ts.Debug.assert(modulekind !== 4); - if (modulekind !== 5) { + ts.Debug.assert(modulekind !== ts.ModuleKind.System); + if (modulekind !== ts.ModuleKind.ES6) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); var generatedName = getGeneratedNameForNode(node); if (node.exportClause) { - if (modulekind !== 2) { + if (modulekind !== ts.ModuleKind.AMD) { write("var "); write(generatedName); write(" = "); @@ -30606,7 +31413,7 @@ var ts; if (hasExportStarsToExportValues && resolver.moduleExportsSomeValue(node.moduleSpecifier)) { writeLine(); write("__export("); - if (modulekind !== 2) { + if (modulekind !== ts.ModuleKind.AMD) { emitRequire(ts.getExternalModuleName(node)); } else { @@ -30638,7 +31445,7 @@ var ts; } } function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(modulekind === 5); + ts.Debug.assert(modulekind === ts.ModuleKind.ES6); var needsComma = false; for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { var specifier = specifiers_1[_a]; @@ -30657,14 +31464,14 @@ var ts; } function emitExportAssignment(node) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (modulekind === 5) { + if (modulekind === ts.ModuleKind.ES6) { writeLine(); emitStart(node); write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 216 && - expression.kind !== 217) { + if (expression.kind !== 217 && + expression.kind !== 218) { write(";"); } emitEnd(node); @@ -30672,7 +31479,7 @@ var ts; else { writeLine(); emitStart(node); - if (modulekind === 4) { + if (modulekind === ts.ModuleKind.System) { write(exportFunctionForFile + "(\"default\","); emit(node.expression); write(")"); @@ -30701,18 +31508,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 225: + case 226: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 224: - if (node.moduleReference.kind === 235 && resolver.isReferencedAliasDeclaration(node)) { + case 225: + if (node.moduleReference.kind === 236 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 231: + case 232: if (node.moduleSpecifier) { if (!node.exportClause) { if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { @@ -30732,7 +31539,7 @@ var ts; } } break; - case 230: + case 231: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -30757,10 +31564,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name); } - if (node.kind === 225 && node.importClause) { + if (node.kind === 226 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 231 && node.moduleSpecifier) { + if (node.kind === 232 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -30785,8 +31592,8 @@ var ts; var started = false; for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { var importNode = externalImports_1[_a]; - var skipNode = importNode.kind === 231 || - (importNode.kind === 225 && !importNode.importClause); + var skipNode = importNode.kind === 232 || + (importNode.kind === 226 && !importNode.importClause); if (skipNode) { continue; } @@ -30811,7 +31618,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { var externalImport = externalImports_2[_a]; - if (externalImport.kind === 231 && externalImport.exportClause) { + if (externalImport.kind === 232 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -30840,7 +31647,7 @@ var ts; } for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { var externalImport = externalImports_3[_d]; - if (externalImport.kind !== 231) { + if (externalImport.kind !== 232) { continue; } var exportDecl = externalImport; @@ -30929,14 +31736,14 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 217 || local.kind === 221 || local.kind === 220) { + if (local.kind === 218 || local.kind === 222 || local.kind === 221) { emitDeclarationName(local); } else { emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); - if (flags & 2) { + if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -30950,7 +31757,7 @@ var ts; var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 2) { + if (f.flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -30960,24 +31767,24 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 4) { + if (node.flags & 2) { return; } - if (node.kind === 216) { + if (node.kind === 217) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 217) { + if (node.kind === 218) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 220) { + if (node.kind === 221) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30986,7 +31793,7 @@ var ts; } return; } - if (node.kind === 221) { + if (node.kind === 222) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30995,7 +31802,7 @@ var ts; } return; } - if (node.kind === 214 || node.kind === 166) { + if (node.kind === 215 || node.kind === 167) { if (shouldHoistVariable(node, false)) { var name_30 = node.name; if (name_30.kind === 69) { @@ -31030,11 +31837,11 @@ var ts; if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { return false; } - return (ts.getCombinedNodeFlags(node) & 24576) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 251; + return (ts.getCombinedNodeFlags(node) & 3072) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 252; } function isCurrentFileSystemExternalModule() { - return modulekind === 4 && isCurrentFileExternalModule; + return modulekind === ts.ModuleKind.System && isCurrentFileExternalModule; } function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); @@ -31069,17 +31876,17 @@ var ts; var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 225: + case 226: if (!entry.importClause) { break; } - case 224: + case 225: ts.Debug.assert(importVariableName !== ""); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 231: + case 232: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { writeLine(); @@ -31123,10 +31930,10 @@ var ts; for (var i = startIndex; i < node.statements.length; i++) { var statement = node.statements[i]; switch (statement.kind) { - case 216: - case 225: + case 217: + case 226: continue; - case 231: + case 232: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -31134,7 +31941,7 @@ var ts; } } continue; - case 224: + case 225: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { continue; } @@ -31157,6 +31964,7 @@ var ts; collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); + contextObjectForFile = makeUniqueName("context"); writeLine(); write("System.register("); writeModuleName(node, emitRelativePathAsModuleName); @@ -31165,13 +31973,17 @@ var ts; var dependencyGroups = []; for (var i = 0; i < externalImports.length; i++) { var text = getExternalModuleNameText(externalImports[i], emitRelativePathAsModuleName); - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; + if (text === undefined) { + continue; + } + var key = text.substr(1, text.length - 2); + if (ts.hasProperty(groupIndices, key)) { + var groupIndex = groupIndices[key]; dependencyGroups[groupIndex].push(externalImports[i]); continue; } else { - groupIndices[text] = dependencyGroups.length; + groupIndices[key] = dependencyGroups.length; dependencyGroups.push([externalImports[i]]); } if (i !== 0) { @@ -31179,10 +31991,13 @@ var ts; } write(text); } - write("], function(" + exportFunctionForFile + ") {"); + write("], function(" + exportFunctionForFile + ", " + contextObjectForFile + ") {"); writeLine(); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true, true); + var startIndex = emitDirectivePrologues(node.statements, true, !compilerOptions.noImplicitUseStrict); + writeLine(); + write("var __moduleName = " + contextObjectForFile + " && " + contextObjectForFile + ".id;"); + writeLine(); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -31254,7 +32069,7 @@ var ts; writeModuleName(node, emitRelativePathAsModuleName); emitAMDDependencies(node, true, emitRelativePathAsModuleName); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true, true); + var startIndex = emitDirectivePrologues(node.statements, true, !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -31265,7 +32080,7 @@ var ts; write("});"); } function emitCommonJSModule(node) { - var startIndex = emitDirectivePrologues(node.statements, false, true); + var startIndex = emitDirectivePrologues(node.statements, false, !compilerOptions.noImplicitUseStrict); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -31284,7 +32099,7 @@ var ts; writeLines(" }\n})("); emitAMDFactoryHeader(dependencyNames); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true, true); + var startIndex = emitDirectivePrologues(node.statements, true, !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -31364,6 +32179,16 @@ var ts; } return result; } + function isJsxChildEmittable(child) { + if (child.kind === 244) { + return !!child.expression; + } + else if (child.kind === 240) { + return !!getTextToEmit(child); + } + return true; + } + ; function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2: @@ -31450,22 +32275,22 @@ var ts; } function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && node.flags & 4194304)) { + if ((languageVersion < 2) && (!extendsEmitted && node.flags & 262144)) { writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && node.flags & 8388608) { + if (!decorateEmitted && node.flags & 524288) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && node.flags & 16777216) { + if (!paramEmitted && node.flags & 1048576) { writeLines(paramHelper); paramEmitted = true; } - if (!awaiterEmitted && node.flags & 33554432) { + if (!awaiterEmitted && node.flags & 2097152) { writeLines(awaiterHelper); awaiterEmitted = true; } @@ -31477,7 +32302,7 @@ var ts; emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (isOwnFileEmit || (!ts.isExternalModule(node) && compilerOptions.isolatedModules)) { - var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ts.ModuleKind.CommonJS]; emitModule(node); } else { @@ -31505,7 +32330,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 4) { + if (node.flags & 2) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -31548,28 +32373,28 @@ var ts; } function isSpecializedCommentHandling(node) { switch (node.kind) { - case 218: - case 216: - case 225: - case 224: case 219: - case 230: + case 217: + case 226: + case 225: + case 220: + case 231: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 196: + case 197: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 221: + case 222: return shouldEmitModuleDeclaration(node); - case 220: + case 221: return shouldEmitEnumDeclaration(node); } ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 195 && + if (node.kind !== 196 && node.parent && - node.parent.kind === 177 && + node.parent.kind === 178 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -31580,13 +32405,13 @@ var ts; switch (node.kind) { case 69: return emitIdentifier(node); - case 139: + case 140: return emitParameter(node); + case 145: case 144: - case 143: return emitMethod(node); - case 146: case 147: + case 148: return emitAccessor(node); case 97: return emitThis(node); @@ -31606,142 +32431,142 @@ var ts; case 13: case 14: return emitLiteral(node); - case 186: - return emitTemplateExpression(node); - case 193: - return emitTemplateSpan(node); - case 236: - case 237: - return emitJsxElement(node); - case 239: - return emitJsxText(node); - case 243: - return emitJsxExpression(node); - case 136: - return emitQualifiedName(node); - case 164: - return emitObjectBindingPattern(node); - case 165: - return emitArrayBindingPattern(node); - case 166: - return emitBindingElement(node); - case 167: - return emitArrayLiteral(node); - case 168: - return emitObjectLiteral(node); - case 248: - return emitPropertyAssignment(node); - case 249: - return emitShorthandPropertyAssignment(node); - case 137: - return emitComputedPropertyName(node); - case 169: - return emitPropertyAccess(node); - case 170: - return emitIndexedAccess(node); - case 171: - return emitCallExpression(node); - case 172: - return emitNewExpression(node); - case 173: - return emitTaggedTemplateExpression(node); - case 174: - return emit(node.expression); - case 192: - return emit(node.expression); - case 175: - return emitParenExpression(node); - case 216: - case 176: - case 177: - return emitFunctionDeclaration(node); - case 178: - return emitDeleteExpression(node); - case 179: - return emitTypeOfExpression(node); - case 180: - return emitVoidExpression(node); - case 181: - return emitAwaitExpression(node); - case 182: - return emitPrefixUnaryExpression(node); - case 183: - return emitPostfixUnaryExpression(node); - case 184: - return emitBinaryExpression(node); - case 185: - return emitConditionalExpression(node); - case 188: - return emitSpreadElementExpression(node); case 187: - return emitYieldExpression(node); - case 190: - return; - case 195: - case 222: - return emitBlock(node); - case 196: - return emitVariableStatement(node); - case 197: - return write(";"); - case 198: - return emitExpressionStatement(node); - case 199: - return emitIfStatement(node); - case 200: - return emitDoStatement(node); - case 201: - return emitWhileStatement(node); - case 202: - return emitForStatement(node); - case 204: - case 203: - return emitForInOrForOfStatement(node); - case 205: - case 206: - return emitBreakOrContinueStatement(node); - case 207: - return emitReturnStatement(node); - case 208: - return emitWithStatement(node); - case 209: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 194: + return emitTemplateSpan(node); + case 237: + case 238: + return emitJsxElement(node); + case 240: + return emitJsxText(node); case 244: - case 245: - return emitCaseOrDefaultClause(node); - case 210: - return emitLabeledStatement(node); - case 211: - return emitThrowStatement(node); - case 212: - return emitTryStatement(node); - case 247: - return emitCatchClause(node); - case 213: - return emitDebuggerStatement(node); - case 214: - return emitVariableDeclaration(node); - case 189: - return emitClassExpression(node); - case 217: - return emitClassDeclaration(node); - case 218: - return emitInterfaceDeclaration(node); - case 220: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 137: + return emitQualifiedName(node); + case 165: + return emitObjectBindingPattern(node); + case 166: + return emitArrayBindingPattern(node); + case 167: + return emitBindingElement(node); + case 168: + return emitArrayLiteral(node); + case 169: + return emitObjectLiteral(node); + case 249: + return emitPropertyAssignment(node); case 250: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 138: + return emitComputedPropertyName(node); + case 170: + return emitPropertyAccess(node); + case 171: + return emitIndexedAccess(node); + case 172: + return emitCallExpression(node); + case 173: + return emitNewExpression(node); + case 174: + return emitTaggedTemplateExpression(node); + case 175: + return emit(node.expression); + case 193: + return emit(node.expression); + case 176: + return emitParenExpression(node); + case 217: + case 177: + case 178: + return emitFunctionDeclaration(node); + case 179: + return emitDeleteExpression(node); + case 180: + return emitTypeOfExpression(node); + case 181: + return emitVoidExpression(node); + case 182: + return emitAwaitExpression(node); + case 183: + return emitPrefixUnaryExpression(node); + case 184: + return emitPostfixUnaryExpression(node); + case 185: + return emitBinaryExpression(node); + case 186: + return emitConditionalExpression(node); + case 189: + return emitSpreadElementExpression(node); + case 188: + return emitYieldExpression(node); + case 191: + return; + case 196: + case 223: + return emitBlock(node); + case 197: + return emitVariableStatement(node); + case 198: + return write(";"); + case 199: + return emitExpressionStatement(node); + case 200: + return emitIfStatement(node); + case 201: + return emitDoStatement(node); + case 202: + return emitWhileStatement(node); + case 203: + return emitForStatement(node); + case 205: + case 204: + return emitForInOrForOfStatement(node); + case 206: + case 207: + return emitBreakOrContinueStatement(node); + case 208: + return emitReturnStatement(node); + case 209: + return emitWithStatement(node); + case 210: + return emitSwitchStatement(node); + case 245: + case 246: + return emitCaseOrDefaultClause(node); + case 211: + return emitLabeledStatement(node); + case 212: + return emitThrowStatement(node); + case 213: + return emitTryStatement(node); + case 248: + return emitCatchClause(node); + case 214: + return emitDebuggerStatement(node); + case 215: + return emitVariableDeclaration(node); + case 190: + return emitClassExpression(node); + case 218: + return emitClassDeclaration(node); + case 219: + return emitInterfaceDeclaration(node); case 221: - return emitModuleDeclaration(node); - case 225: - return emitImportDeclaration(node); - case 224: - return emitImportEqualsDeclaration(node); - case 231: - return emitExportDeclaration(node); - case 230: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 251: + return emitEnumMember(node); + case 222: + return emitModuleDeclaration(node); + case 226: + return emitImportDeclaration(node); + case 225: + return emitImportEqualsDeclaration(node); + case 232: + return emitExportDeclaration(node); + case 231: + return emitExportAssignment(node); + case 252: return emitSourceFileNode(node); } } @@ -31771,7 +32596,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 251 || node.pos !== node.parent.pos) { + if (node.parent.kind === 252 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -31783,7 +32608,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 251 || node.end !== node.parent.end) { + if (node.parent.kind === 252 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentText, node.end); } } @@ -31885,7 +32710,7 @@ var ts; ts.ioReadTime = 0; ts.ioWriteTime = 0; var emptyArray = []; - ts.version = "1.8.0"; + ts.version = "1.9.0"; function findConfigFile(searchPath, fileExists) { var fileName = "tsconfig.json"; while (true) { @@ -31908,94 +32733,331 @@ var ts; 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, compilerOptions, host); - case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + function trace(host, message) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceModuleResolution && host.trace !== undefined; + } + function startsWith(str, prefix) { + return str.lastIndexOf(prefix, 0) === 0; + } + function endsWith(str, suffix) { + var expectedPos = str.length - suffix.length; + return str.indexOf(suffix, expectedPos) === expectedPos; + } + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + return false; + } + } } + return true; + } + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + } + function moduleHasNonRelativeName(moduleName) { + if (ts.isRootedDiskPath(moduleName)) { + return false; + } + var i = moduleName.lastIndexOf("./", 1); + var startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === 46); + return !startsWithDotSlashOrDotDotSlash; + } + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; } ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } + } + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var longestMatchPrefixLength = -1; + var matchedPattern; + var matchedStar; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + for (var key in state.compilerOptions.paths) { + var pattern = key; + var indexOfStar = pattern.indexOf("*"); + if (indexOfStar !== -1) { + var prefix = pattern.substr(0, indexOfStar); + var suffix = pattern.substr(indexOfStar + 1); + if (moduleName.length >= prefix.length + suffix.length && + startsWith(moduleName, prefix) && + endsWith(moduleName, suffix)) { + if (prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = prefix.length; + matchedPattern = pattern; + matchedStar = moduleName.substr(prefix.length, moduleName.length - suffix.length); + } + } + } + else if (pattern === moduleName) { + matchedPattern = pattern; + matchedStar = undefined; + break; + } + } + } + if (matchedPattern) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPattern); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPattern]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("\*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { - var failedLookupLocations = []; - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(supportedExtensions, candidate, failedLookupLocations, false, host); - if (resolvedFileName) { - return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, false, failedLookupLocations); + } + var isExternalLibraryImport = false; + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, false, host); - return resolvedFileName - ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state); + isExternalLibraryImport = resolvedFileName !== undefined; } else { - return loadModuleFromNodeModules(moduleName, containingDirectory, host); + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; - function loadNodeModuleFromFile(extensions, candidate, failedLookupLocation, onlyRecordFailures, host) { + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { return ts.forEach(extensions, tryLoad); function tryLoad(ext) { + if (ext === ".tsx" && state.skipTsx) { + return undefined; + } var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (!onlyRecordFailures && host.fileExists(fileName)) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_module_resolution_result, fileName); + } return fileName; } else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } failedLookupLocation.push(fileName); return undefined; } } } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, host) { + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, host); - if (directoryExists && host.fileExists(packageJsonPath)) { + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } var jsonContent; try { - var jsonText = host.readFile(packageJsonPath); + var jsonText = state.host.readFile(packageJsonPath); jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; } catch (e) { jsonContent = { typings: undefined }; } - if (typeof jsonContent.typings === "string") { - var path = ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)); - var result = loadNodeModuleFromFile(extensions, path, failedLookupLocation, !directoryProbablyExists(ts.getDirectoryPath(path), host), host); - if (result) { - return result; + if (jsonContent.typings) { + if (typeof jsonContent.typings === "string") { + var typingsFile = ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_typings_field_0_that_references_1, jsonContent.typings, typingsFile); + } + var result = loadModuleFromFile(typingsFile, extensions, failedLookupLocation, !directoryProbablyExists(ts.getDirectoryPath(typingsFile), state.host), state); + if (result) { + return result; + } + } + else if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_typings_field_in_package_json_to_be_string_got_0, typeof jsonContent.typings); + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_typings_field); } } } else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, host); + return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); } - function loadModuleFromNodeModules(moduleName, directory, host) { - var failedLookupLocations = []; + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state) { directory = ts.normalizeSlashes(directory); while (true) { var baseName = ts.getBaseFileName(directory); if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, host); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host); + var result = loadModuleFromFile(candidate, ts.supportedTypeScriptExtensions, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + return result; } - result = loadNodeModuleFromDirectory(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host); + result = loadNodeModuleFromDirectory(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + return result; } } var parentPath = ts.getDirectoryPath(directory); @@ -32004,43 +33066,36 @@ var ts; } directory = parentPath; } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - function nameStartsWithDotSlashOrDotDotSlash(name) { - var i = name.lastIndexOf("./", 1); - return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + return undefined; } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf("!") != -1) { - return { resolvedModule: undefined, failedLookupLocations: [] }; - } - var searchPath = ts.getDirectoryPath(containingFile); - var searchName; + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; var failedLookupLocations = []; - var referencedSourceFile; var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(supportedExtensions, function (extension) { - if (extension === ".tsx" && !compilerOptions.jsx) { - return undefined; + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, false, failedLookupLocations); + } + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + if (referencedSourceFile) { + break; } - var candidate = searchName + extension; - if (host.fileExists(candidate)) { - return candidate; + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + break; } - else { - failedLookupLocations.push(candidate); - } - }); - if (referencedSourceFile) { - break; + containingDirectory = parentPath; } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); } return referencedSourceFile ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } @@ -32048,7 +33103,7 @@ var ts; } ts.classicNameResolver = classicNameResolver; ts.defaultInitCompilerOptions = { - module: 1, + module: ts.ModuleKind.CommonJS, target: 1, noImplicitAny: false, sourceMap: false @@ -32117,6 +33172,7 @@ var ts; getNewLine: function () { return newLine; }, fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, readFile: function (fileName) { return ts.sys.readFile(fileName); }, + trace: function (s) { return ts.sys.write(s + newLine); }, directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); } }; } @@ -32353,10 +33409,17 @@ var ts; return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + var declarationDiagnostics = []; + if (options.noEmit) { + return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true }; + } if (options.noEmitOnError) { - var preEmitDiagnostics = getPreEmitDiagnostics(program, undefined, cancellationToken); - if (preEmitDiagnostics.length > 0) { - return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true }; + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (diagnostics.length === 0 && program.getCompilerOptions().declaration) { + declarationDiagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken); + } + if (diagnostics.length > 0 || declarationDiagnostics.length > 0) { + return { diagnostics: diagnostics, sourceMaps: undefined, emitSkipped: true }; } } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); @@ -32428,44 +33491,47 @@ var ts; return false; } switch (node.kind) { - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 230: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - case 217: + case 231: + if (node.isExportEquals) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 218: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 246: + case 247: var heritageClause = node; if (heritageClause.token === 106) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 218: + case 219: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 221: + case 222: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 219: + case 220: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 144: - case 143: case 145: + case 144: case 146: case 147: - case 176: - case 216: + case 148: case 177: - case 216: + case 217: + case 178: + case 217: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -32473,20 +33539,20 @@ var ts; return true; } break; - case 196: + case 197: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 214: + case 215: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 171: case 172: + case 173: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start_2 = expression.typeArguments.pos; @@ -32494,7 +33560,7 @@ var ts; return true; } break; - case 139: + case 140: var parameter = node; if (parameter.modifiers) { var start_3 = parameter.modifiers.pos; @@ -32510,18 +33576,20 @@ var ts; return true; } break; - case 142: + case 143: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 220: + case 221: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 174: + case 175: 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 140: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); + case 141: + if (!options.experimentalDecorators) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + } return true; } return ts.forEachChild(node, walk); @@ -32549,6 +33617,7 @@ var ts; case 112: case 110: case 111: + case 127: case 122: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; @@ -32619,9 +33688,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 226: case 225: - case 224: - case 231: + case 232: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -32633,8 +33702,8 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 221: - if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 4 || ts.isDeclarationFile(file))) { + case 222: + if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 2 || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); @@ -32649,7 +33718,7 @@ var ts; } } function collectRequireCalls(node) { - if (ts.isRequireCall(node)) { + if (ts.isRequireCall(node, true)) { (imports || (imports = [])).push(node.arguments[0]); } else { @@ -32772,7 +33841,7 @@ var ts; if (shouldAddFile) { var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { - if (!ts.isExternalModule(importedFile)) { + if (!ts.isExternalModule(importedFile) && importedFile.statements.length) { var start_5 = ts.getTokenPosOfNode(file.imports[i], file); fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_5, file.imports[i].end - start_5, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); } @@ -32862,6 +33931,25 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } } + if (options.paths && options.baseUrl === undefined) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option)); + } + if (options.paths) { + for (var key in options.paths) { + if (!ts.hasProperty(options.paths, key)) { + continue; + } + if (!hasZeroOrOneAsteriskCharacter(key)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); + } + for (var _i = 0, _a = options.paths[key]; _i < _a.length; _i++) { + var subst = _a[_i]; + if (!hasZeroOrOneAsteriskCharacter(subst)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); + } + } + } + } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); @@ -32885,7 +33973,7 @@ var ts; 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) { + if (options.module === ts.ModuleKind.None && languageVersion < 2) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -32894,14 +33982,14 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { + else if (firstExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) { var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); } - if (options.module === 5 && languageVersion < 2) { + if (options.module === ts.ModuleKind.ES6 && languageVersion < 2) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); } - if (outFile && options.module && !(options.module === 2 || options.module === 4)) { + if (outFile && options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); } if (options.outDir || @@ -32934,9 +34022,9 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.reactNamespace && !ts.isIdentifier(options.reactNamespace, languageVersion)) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); } - if (!options.noEmit) { + if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { @@ -33040,16 +34128,17 @@ var ts; name: "module", shortName: "m", type: { - "commonjs": 1, - "amd": 2, - "system": 4, - "umd": 3, - "es6": 5, - "es2015": 5 + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES6, + "es2015": ts.ModuleKind.ES2015 }, description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none }, { name: "newLine", @@ -33215,8 +34304,8 @@ var ts; { name: "moduleResolution", type: { - "node": 2, - "classic": 1 + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic }, description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic @@ -33247,14 +34336,41 @@ var ts; description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { - name: "allowSyntheticDefaultImports", + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "object", + isTSConfigOnly: true, + isFilePath: true + }, + { + name: "traceModuleResolution", type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + description: ts.Diagnostics.Enable_tracing_of_the_module_resolution_process }, { name: "allowJs", type: "boolean", description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output } ]; var optionNameMapCache; @@ -33300,31 +34416,36 @@ var ts; } if (ts.hasProperty(optionNameMap, s)) { var opt = optionNameMap[s]; - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - default: - var map_1 = opt.type; - var key = (args[i] || "").toLowerCase(); - i++; - if (ts.hasProperty(map_1, key)) { - options[opt.name] = map_1[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - } + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + default: + var map_1 = opt.type; + var key = (args[i] || "").toLowerCase(); + i++; + if (ts.hasProperty(map_1, key)) { + options[opt.name] = map_1[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + } + } } } else { @@ -33410,9 +34531,9 @@ var ts; } return output; } - function parseJsonConfigFileContent(json, host, basePath, existingOptions) { + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName) { if (existingOptions === void 0) { existingOptions = {}; } - var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), optionsFromJsonConfigFile = _a.options, errors = _a.errors; + var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath, configFileName), optionsFromJsonConfigFile = _a.options, errors = _a.errors; var options = ts.extend(existingOptions, optionsFromJsonConfigFile); return { options: options, @@ -33431,7 +34552,18 @@ var ts; } else { var filesSeen = {}; - var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; + var exclude = []; + if (json["exclude"] instanceof Array) { + exclude = json["exclude"]; + } + else { + exclude = ["node_modules"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + exclude.push(outDir); + } + } + exclude = ts.map(exclude, ts.normalizeSlashes); var supportedExtensions = ts.getSupportedExtensions(options); ts.Debug.assert(ts.indexOf(supportedExtensions, ".ts") < ts.indexOf(supportedExtensions, ".d.ts"), "Changed priority of extensions to pick"); for (var _i = 0, supportedExtensions_1 = supportedExtensions; _i < supportedExtensions_1.length; _i++) { @@ -33442,6 +34574,9 @@ var ts; if (extension === ".ts" && ts.fileExtensionIs(fileName, ".d.ts")) { continue; } + if (/\.min\.js$/.test(fileName)) { + continue; + } if (extension === ".d.ts" || (options.allowJs && ts.contains(ts.supportedJavascriptExtensions, extension))) { var baseName = fileName.substr(0, fileName.length - extension.length); if (ts.hasProperty(filesSeen, baseName + ".ts") || ts.hasProperty(filesSeen, baseName + ".tsx")) { @@ -33457,9 +34592,12 @@ var ts; } } ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompilerOptionsFromJson(jsonOptions, basePath) { + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var options = {}; var errors = []; + if (configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json") { + options.allowJs = true; + } if (!jsonOptions) { return { options: options, errors: errors }; } @@ -33482,7 +34620,36 @@ var ts; } } if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + switch (typeof value) { + case "string": + value = ts.normalizePath(ts.combinePaths(basePath, value)); + break; + case "object": + var paths = []; + var invalidOptionType = false; + if (!ts.isArray(value)) { + invalidOptionType = true; + } + else { + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + if (typeof element === "string") { + paths.push(ts.normalizePath(ts.combinePaths(basePath, element))); + } + else { + invalidOptionType = true; + break; + } + } + } + if (invalidOptionType) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_should_have_array_of_strings_as_a_value, opt.name)); + } + else { + value = paths; + } + break; + } if (value === "") { value = "."; } @@ -33588,7 +34755,7 @@ var ts; var gutterStyleSequence = "\u001b[100;30m"; var gutterSeparator = " "; var resetEscapeSequence = "\u001b[0m"; - var elipsis = "..."; + var ellipsis = "..."; var categoryFormatMap = (_a = {}, _a[ts.DiagnosticCategory.Warning] = yellowForegroundEscapeSequence, _a[ts.DiagnosticCategory.Error] = redForegroundEscapeSequence, @@ -33609,12 +34776,12 @@ var ts; var hasMoreThanFiveLines = (lastLine - firstLine) >= 4; var gutterWidth = (lastLine + 1 + "").length; if (hasMoreThanFiveLines) { - gutterWidth = Math.max(elipsis.length, gutterWidth); + gutterWidth = Math.max(ellipsis.length, gutterWidth); } output += ts.sys.newLine; for (var i = firstLine; i <= lastLine; i++) { if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(elipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + ts.sys.newLine; + output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + ts.sys.newLine; i = lastLine - 1; } var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); @@ -33682,6 +34849,9 @@ var ts; function isJSONSupported() { return typeof JSON === "object" && typeof JSON.parse === "function"; } + function isWatchSet(options) { + return options.watch && options.hasOwnProperty("watch"); + } function executeCommandLine(args) { var commandLine = ts.parseCommandLine(args); var configFileName; @@ -33755,7 +34925,7 @@ var ts; printHelp(); return ts.sys.exit(ts.ExitStatus.Success); } - if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { + if (isWatchSet(commandLine.options)) { if (!ts.sys.watchFile) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), undefined); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); @@ -33795,7 +34965,7 @@ var ts; ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); return; } - var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, ts.getDirectoryPath(configFileName), commandLine.options); + var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), ts.sys.getCurrentDirectory()), commandLine.options, configFileName); if (configParseResult.errors.length > 0) { reportDiagnostics(configParseResult.errors, undefined); ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); @@ -33825,7 +34995,7 @@ var ts; } cachedExistingFiles = {}; var compileResult = compile(rootFileNames, compilerOptions, compilerHost); - if (!compilerOptions.watch) { + if (!isWatchSet(compilerOptions)) { return ts.sys.exit(compileResult.exitStatus); } setCachedProgram(compileResult.program); @@ -33845,7 +35015,7 @@ var ts; } } var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); - if (sourceFile && compilerOptions.watch) { + if (sourceFile && isWatchSet(compilerOptions)) { var filePath = ts.toPath(sourceFile.fileName, ts.sys.getCurrentDirectory(), ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); sourceFile.fileWatcher = ts.sys.watchFile(filePath, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); } @@ -33882,7 +35052,7 @@ var ts; startTimerForRecompilation(); } function watchedDirectoryChanged(fileName) { - if (fileName && !ts.isSupportedSourceFileName(fileName, commandLine.options)) { + if (fileName && !ts.isSupportedSourceFileName(fileName, compilerOptions)) { return; } startTimerForHandlingDirectoryChanges(); @@ -33958,18 +35128,13 @@ var ts; diagnostics = program.getSemanticDiagnostics(); } } - reportDiagnostics(diagnostics, compilerHost); - if (compilerOptions.noEmit) { - return diagnostics.length - ? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped - : ts.ExitStatus.Success; - } var emitOutput = program.emit(); - reportDiagnostics(emitOutput.diagnostics, compilerHost); - if (emitOutput.emitSkipped) { + diagnostics = diagnostics.concat(emitOutput.diagnostics); + reportDiagnostics(ts.sortAndDeduplicateDiagnostics(diagnostics), compilerHost); + if (emitOutput.emitSkipped && diagnostics.length > 0) { return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } - if (diagnostics.length > 0 || emitOutput.diagnostics.length > 0) { + else if (diagnostics.length > 0) { return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated; } return ts.ExitStatus.Success; @@ -34045,12 +35210,17 @@ var ts; else { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions), - exclude: ["node_modules"] + compilerOptions: serializeCompilerOptions(compilerOptions) }; if (fileNames && fileNames.length) { configurations.files = fileNames; } + else { + configurations.exclude = ["node_modules"]; + if (compilerOptions.outDir) { + configurations.exclude.push(compilerOptions.outDir); + } + } ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file), undefined); } diff --git a/lib/tsserver.js b/lib/tsserver.js index ba62ebe0dde..8c33f866268 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -13,6 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +var __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 ts; (function (ts) { var OperationCanceledException = (function () { @@ -46,6 +51,21 @@ 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"; + ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; + ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; + ModuleKind[ModuleKind["System"] = 4] = "System"; + ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; + ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; + })(ts.ModuleKind || (ts.ModuleKind = {})); + var ModuleKind = ts.ModuleKind; })(ts || (ts = {})); var ts; (function (ts) { @@ -410,6 +430,14 @@ var ts; }; } ts.createFileDiagnostic = createFileDiagnostic; + function formatMessage(dummy, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); + } + return text; + } + ts.formatMessage = formatMessage; function createCompilerDiagnostic(message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 1) { @@ -1042,7 +1070,7 @@ var ts; var filePath = typeof relativeFileName !== "string" ? undefined : ts.toPath(relativeFileName, baseDirPath, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); - if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) { + if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks.contains(filePath)) { for (var _i = 0, _a = fileWatcherCallbacks.get(filePath); _i < _a.length; _i++) { var fileCallback = _a[_i]; fileCallback(filePath); @@ -1058,7 +1086,7 @@ var ts; var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { + if (!fileExists(fileName)) { return undefined; } var buffer = _fs.readFileSync(fileName); @@ -1098,6 +1126,24 @@ var ts; function getCanonicalPath(path) { return useCaseSensitiveFileNames ? path : path.toLowerCase(); } + function fileSystemEntryExists(path, entryKind) { + try { + var stat = _fs.statSync(path); + switch (entryKind) { + case 0: return stat.isFile(); + case 1: return stat.isDirectory(); + } + } + catch (e) { + return false; + } + } + function fileExists(path) { + return fileSystemEntryExists(path, 0); + } + function directoryExists(path) { + return fileSystemEntryExists(path, 1); + } function readDirectory(path, extension, exclude) { var result = []; exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); @@ -1161,12 +1207,8 @@ var ts; resolvePath: function (path) { return _path.resolve(path); }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, + fileExists: fileExists, + directoryExists: directoryExists, createDirectory: function (directoryName) { if (!this.directoryExists(directoryName)) { _fs.mkdirSync(directoryName); @@ -1249,6 +1291,7 @@ var ts; An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_a_type_annotation_1021", message: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_must_have_a_type_annotation_1022", message: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_type_must_be_string_or_number_1023", message: "An index signature parameter type must be 'string' or 'number'." }, + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: { code: 1024, category: ts.DiagnosticCategory.Error, key: "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", message: "'readonly' modifier can only appear on a property declaration or index signature." }, Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility_modifier_already_seen_1028", message: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "_0_modifier_must_precede_1_modifier_1029", message: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "_0_modifier_already_seen_1030", message: "'{0}' modifier already seen." }, @@ -1262,7 +1305,7 @@ var ts; _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_a_class_declaration_1041", message: "'{0}' modifier cannot be used with a class declaration." }, _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_here_1042", message: "'{0}' modifier cannot be used here." }, _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_data_property_1043", message: "'{0}' modifier cannot appear on a data property." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_element_1044", message: "'{0}' modifier cannot appear on a module element." }, + _0_modifier_cannot_appear_on_a_module_or_namespace_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", message: "'{0}' modifier cannot appear on a module or namespace element." }, A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", message: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", message: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_be_optional_1047", message: "A rest parameter cannot be optional." }, @@ -1281,8 +1324,11 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum_member_must_have_initializer_1061", message: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_namespace_1063", message: "An export assignment cannot be used in a namespace." }, + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { code: 1064, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", message: "The return type of an async function or method must be the global Promise type." }, In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", message: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", message: "Unexpected token. A constructor, method, accessor, or property was expected." }, + _0_modifier_cannot_appear_on_a_type_member: { code: 1070, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_type_member_1070", message: "'{0}' modifier cannot appear on a type member." }, + _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, @@ -1338,10 +1384,9 @@ var ts; String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String_literal_expected_1141", message: "String literal expected." }, Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line_break_not_permitted_here_1142", message: "Line break not permitted here." }, or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers_not_permitted_on_index_signature_members_1145", message: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." }, Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." }, - Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_optio_1148", message: "Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file." }, + Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting__1148", message: "Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" }, @@ -1401,7 +1446,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Speci_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_6_or_higher_1220", message: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators_are_not_allowed_in_an_ambient_context_1221", message: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An_overload_signature_cannot_be_declared_as_a_generator_1222", message: "An overload signature cannot be declared as a generator." }, @@ -1410,6 +1455,7 @@ var ts; Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, @@ -1423,7 +1469,7 @@ var ts; Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", message: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", message: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", message: "Unable to resolve signature of method decorator when called as an expression." }, - abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_or_method_declaration_1242", message: "'abstract' modifier can only appear on a class or method declaration." }, + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", message: "'abstract' modifier can only appear on a class, method, or property declaration." }, _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_1_modifier_1243", message: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract_methods_can_only_appear_within_an_abstract_class_1244", message: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", message: "Method '{0}' cannot have an implementation because it is marked abstract." }, @@ -1516,7 +1562,7 @@ var ts; get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", message: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_not_exported_2383", message: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_exported_or_non_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_non_exported_2383", message: "Overload signatures must all be exported or non-exported." }, Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", message: "Overload signatures must all be ambient or non-ambient." }, Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_public_private_or_protected_2385", message: "Overload signatures must all be public, private or protected." }, Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_optional_or_required_2386", message: "Overload signatures must all be optional or required." }, @@ -1549,7 +1595,6 @@ var ts; Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class_name_cannot_be_0_2414", message: "Class name cannot be '{0}'" }, Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_extends_base_class_1_2415", message: "Class '{0}' incorrectly extends base class '{1}'." }, Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", message: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0_2419", message: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_implements_interface_1_2420", message: "Class '{0}' incorrectly implements interface '{1}'." }, A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_implement_another_class_or_interface_2422", message: "A class may only implement another class or interface." }, Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, @@ -1557,7 +1602,7 @@ var ts; Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface_name_cannot_be_0_2427", message: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_interface_must_have_identical_type_parameters_2428", message: "All declarations of an interface must have identical type parameters." }, + All_declarations_of_0_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_type_parameters_2428", message: "All declarations of '{0}' must have identical type parameters." }, Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface_0_incorrectly_extends_interface_1_2430", message: "Interface '{0}' incorrectly extends interface '{1}'." }, Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum_name_cannot_be_0_2431", message: "Enum name cannot be '{0}'" }, In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", message: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, @@ -1577,8 +1622,8 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_2449", message: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_2450", message: "Left-hand side of assignment expression cannot be a constant." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -1611,8 +1656,8 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant_2485", message: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant_2486", message: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, @@ -1638,7 +1683,7 @@ var ts; Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", message: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base_constructors_must_all_have_the_same_return_type_2510", message: "Base constructors must all have the same return type." }, Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot_create_an_instance_of_the_abstract_class_0_2511", message: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_not_abstract_2512", message: "Overload signatures must all be abstract or not abstract." }, + Overload_signatures_must_all_be_abstract_or_non_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", message: "Overload signatures must all be abstract or non-abstract." }, Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", message: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes_containing_abstract_methods_must_be_marked_abstract_2514", message: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", message: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, @@ -1654,6 +1699,8 @@ var ts; A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", message: "A 'this' type is available only in a non-static member of a class or interface." }, The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary_2527", message: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A_module_cannot_have_multiple_default_exports_2528", message: "A module cannot have multiple default exports." }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { code: 2529, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions." }, + Property_0_is_incompatible_with_index_signature: { code: 2530, category: ts.DiagnosticCategory.Error, key: "Property_0_is_incompatible_with_index_signature_2530", message: "Property '{0}' is incompatible with index signature." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1683,6 +1730,12 @@ var ts; export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { code: 2669, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", message: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations." }, Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { code: 2670, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", message: "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context." }, + Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { code: 2671, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671", message: "Cannot augment module '{0}' because it resolves to a non-module entity." }, + Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: { code: 2672, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_a_0_constructor_type_to_a_1_constructor_type_2672", message: "Cannot assign a '{0}' constructor type to a '{1}' constructor type." }, + Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: { code: 2673, category: ts.DiagnosticCategory.Error, key: "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673", message: "Constructor of class '{0}' is private and only accessible within the class declaration." }, + Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: { code: 2674, category: ts.DiagnosticCategory.Error, key: "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674", message: "Constructor of class '{0}' is protected and only accessible within the class declaration." }, + Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: { code: 2675, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_a_class_0_Class_constructor_is_marked_as_private_2675", message: "Cannot extend a class '{0}'. Class constructor is marked as private." }, + Accessors_must_both_be_abstract_or_non_abstract: { code: 2676, category: ts.DiagnosticCategory.Error, key: "Accessors_must_both_be_abstract_or_non_abstract_2676", message: "Accessors must both be abstract or non-abstract." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1771,7 +1824,10 @@ var ts; Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { code: 5056, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056", message: "Cannot write file '{0}' because it would be overwritten by multiple input files." }, Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { code: 5057, category: ts.DiagnosticCategory.Error, key: "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057", message: "Cannot find a tsconfig.json file at the specified directory: '{0}'" }, The_specified_path_does_not_exist_Colon_0: { code: 5058, category: ts.DiagnosticCategory.Error, key: "The_specified_path_does_not_exist_Colon_0_5058", message: "The specified path does not exist: '{0}'" }, - Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier: { code: 5059, category: ts.DiagnosticCategory.Error, key: "Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", message: "Invalide value for '--reactNamespace'. '{0}' is not a valid identifier." }, + Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: { code: 5059, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", message: "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier." }, + Option_paths_cannot_be_used_without_specifying_baseUrl_option: { code: 5060, category: ts.DiagnosticCategory.Error, key: "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", message: "Option 'paths' cannot be used without specifying '--baseUrl' option." }, + Pattern_0_can_have_at_most_one_Asterisk_character: { code: 5061, category: ts.DiagnosticCategory.Error, key: "Pattern_0_can_have_at_most_one_Asterisk_character_5061", message: "Pattern '{0}' can have at most one '*' character" }, + Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { code: 5062, category: ts.DiagnosticCategory.Error, key: "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", message: "Substitution '{0}' in pattern '{1}' in can have at most one '*' character" }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, 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_6003", message: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1805,7 +1861,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated_quoted_string_in_response_file_0_6045", message: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'none'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument_for_target_option_must_be_ES3_ES5_or_ES2015_6047", message: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", message: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported_locale_0_6049", message: "Unsupported locale '{0}'." }, @@ -1822,6 +1878,7 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, + Option_0_can_only_be_specified_in_tsconfig_json_file: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", message: "Option '{0}' can only be specified in 'tsconfig.json' file." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "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_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -1838,8 +1895,36 @@ var ts; Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "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_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, - Allow_javascript_files_to_be_compiled: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6083", message: "Allow javascript files to be compiled." }, + Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specifies the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Enable_tracing_of_the_module_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_module_resolution_process_6085", message: "Enable tracing of the module resolution process." }, + Resolving_module_0_from_1: { code: 6086, category: ts.DiagnosticCategory.Message, key: "Resolving_module_0_from_1_6086", message: "======== Resolving module '{0}' from '{1}'. ========" }, + Explicitly_specified_module_resolution_kind_Colon_0: { code: 6087, category: ts.DiagnosticCategory.Message, key: "Explicitly_specified_module_resolution_kind_Colon_0_6087", message: "Explicitly specified module resolution kind: '{0}'." }, + Module_resolution_kind_is_not_specified_using_0: { code: 6088, category: ts.DiagnosticCategory.Message, key: "Module_resolution_kind_is_not_specified_using_0_6088", message: "Module resolution kind is not specified, using '{0}'." }, + Module_name_0_was_successfully_resolved_to_1: { code: 6089, category: ts.DiagnosticCategory.Message, key: "Module_name_0_was_successfully_resolved_to_1_6089", message: "======== Module name '{0}' was successfully resolved to '{1}'. ========" }, + Module_name_0_was_not_resolved: { code: 6090, category: ts.DiagnosticCategory.Message, key: "Module_name_0_was_not_resolved_6090", message: "======== Module name '{0}' was not resolved. ========" }, + paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: { code: 6091, category: ts.DiagnosticCategory.Message, key: "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091", message: "'paths' option is specified, looking for a pattern to match module name '{0}'." }, + Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, + Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, + Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, + File_0_exist_use_it_as_a_module_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_module_resolution_result_6097", message: "File '{0}' exist - use it as a module resolution result." }, + Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, + package_json_does_not_have_typings_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_typings_field_6100", message: "'package.json' does not have 'typings' field." }, + package_json_has_typings_field_0_that_references_1: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_typings_field_0_that_references_1_6101", message: "'package.json' has 'typings' field '{0}' that references '{1}'." }, + Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, + Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, + Checking_if_0_is_the_longest_matching_prefix_for_1_2: { code: 6104, category: ts.DiagnosticCategory.Message, key: "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104", message: "Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'." }, + Expected_type_of_typings_field_in_package_json_to_be_string_got_0: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_typings_field_in_package_json_to_be_string_got_0_6105", message: "Expected type of 'typings' field in 'package.json' to be 'string', got '{0}'." }, + baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: { code: 6106, category: ts.DiagnosticCategory.Message, key: "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106", message: "'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'" }, + rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: { code: 6107, category: ts.DiagnosticCategory.Message, key: "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107", message: "'rootDirs' option is set, using it to resolve relative module name '{0}'" }, + Longest_matching_prefix_for_0_is_1: { code: 6108, category: ts.DiagnosticCategory.Message, key: "Longest_matching_prefix_for_0_is_1_6108", message: "Longest matching prefix for '{0}' is '{1}'" }, + Loading_0_from_the_root_dir_1_candidate_location_2: { code: 6109, category: ts.DiagnosticCategory.Message, key: "Loading_0_from_the_root_dir_1_candidate_location_2_6109", message: "Loading '{0}' from the root dir '{1}', candidate location '{2}'" }, + Trying_other_entries_in_rootDirs: { code: 6110, category: ts.DiagnosticCategory.Message, key: "Trying_other_entries_in_rootDirs_6110", message: "Trying other entries in 'rootDirs'" }, + Module_resolution_using_rootDirs_has_failed: { code: 6111, category: ts.DiagnosticCategory.Message, key: "Module_resolution_using_rootDirs_has_failed_6111", message: "Module resolution using 'rootDirs' has failed" }, + Do_not_emit_use_strict_directives_in_module_output: { code: 6112, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_use_strict_directives_in_module_output_6112", message: "Do not emit 'use strict' directives in module output." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -1878,7 +1963,6 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "property_declarations_can_only_be_used_in_a_ts_file_8014", message: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "enum_declarations_can_only_be_used_in_a_ts_file_8015", message: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", message: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "decorators_can_only_be_used_in_a_ts_file_8017", message: "'decorators' can only be used in a .ts file." }, Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -1889,7 +1973,8 @@ var ts; 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_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", message: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, - JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." } + JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." }, + super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." } }; })(ts || (ts = {})); var ts; @@ -1922,7 +2007,7 @@ var ts; "false": 84, "finally": 85, "for": 86, - "from": 133, + "from": 134, "function": 87, "get": 123, "if": 88, @@ -1937,25 +2022,26 @@ var ts; "namespace": 126, "new": 92, "null": 93, - "number": 128, + "number": 129, "package": 109, "private": 110, "protected": 111, "public": 112, - "require": 127, - "global": 134, + "readonly": 127, + "require": 128, + "global": 135, "return": 94, - "set": 129, + "set": 130, "static": 113, - "string": 130, + "string": 131, "super": 95, "switch": 96, - "symbol": 131, + "symbol": 132, "this": 97, "throw": 98, "true": 99, "try": 100, - "type": 132, + "type": 133, "typeof": 101, "var": 102, "void": 103, @@ -1964,7 +2050,7 @@ var ts; "yield": 114, "async": 118, "await": 119, - "of": 135, + "of": 136, "{": 15, "}": 16, "(": 17, @@ -2446,6 +2532,7 @@ var ts; scanJsxIdentifier: scanJsxIdentifier, reScanJsxToken: reScanJsxToken, scanJsxToken: scanJsxToken, + scanJSDocToken: scanJSDocToken, scan: scan, setText: setText, setScriptTarget: setScriptTarget, @@ -2453,7 +2540,8 @@ var ts; setOnError: setOnError, setTextPos: setTextPos, tryScan: tryScan, - lookAhead: lookAhead + lookAhead: lookAhead, + scanRange: scanRange }; function error(message, length) { if (onError) { @@ -3225,7 +3313,7 @@ var ts; break; } } - return token = 239; + return token = 240; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -3243,6 +3331,54 @@ var ts; } return token; } + function scanJSDocToken() { + if (pos >= end) { + return token = 1; + } + startPos = pos; + var ch = text.charCodeAt(pos); + while (pos < end) { + ch = text.charCodeAt(pos); + if (isWhiteSpace(ch)) { + pos++; + } + else { + break; + } + } + tokenPos = pos; + switch (ch) { + case 64: + return pos += 1, token = 55; + case 10: + case 13: + return pos += 1, token = 4; + case 42: + return pos += 1, token = 37; + case 123: + return pos += 1, token = 15; + case 125: + return pos += 1, token = 16; + case 91: + return pos += 1, token = 19; + case 93: + return pos += 1, token = 20; + case 61: + return pos += 1, token = 56; + case 44: + return pos += 1, token = 24; + } + if (isIdentifierStart(ch, 2)) { + pos++; + while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { + pos++; + } + return token = 69; + } + else { + return pos += 1, token = 0; + } + } function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; @@ -3261,6 +3397,29 @@ var ts; } return result; } + function scanRange(start, length, callback) { + var saveEnd = end; + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var savePrecedingLineBreak = precedingLineBreak; + var saveTokenValue = tokenValue; + var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; + var saveTokenIsUnterminated = tokenIsUnterminated; + setText(text, start, length); + var result = callback(); + end = saveEnd; + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + precedingLineBreak = savePrecedingLineBreak; + tokenValue = saveTokenValue; + hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; + tokenIsUnterminated = saveTokenIsUnterminated; + return result; + } function lookAhead(callback) { return speculationHelper(callback, true); } @@ -3369,16 +3528,17 @@ var ts; name: "module", shortName: "m", type: { - "commonjs": 1, - "amd": 2, - "system": 4, - "umd": 3, - "es6": 5, - "es2015": 5 + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES6, + "es2015": ts.ModuleKind.ES2015 }, description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none }, { name: "newLine", @@ -3544,8 +3704,8 @@ var ts; { name: "moduleResolution", type: { - "node": 2, - "classic": 1 + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic }, description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic @@ -3576,14 +3736,41 @@ var ts; description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { - name: "allowSyntheticDefaultImports", + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "object", + isTSConfigOnly: true, + isFilePath: true + }, + { + name: "traceModuleResolution", type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + description: ts.Diagnostics.Enable_tracing_of_the_module_resolution_process }, { name: "allowJs", type: "boolean", description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output } ]; var optionNameMapCache; @@ -3629,31 +3816,36 @@ var ts; } if (ts.hasProperty(optionNameMap, s)) { var opt = optionNameMap[s]; - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - default: - var map_1 = opt.type; - var key = (args[i] || "").toLowerCase(); - i++; - if (ts.hasProperty(map_1, key)) { - options[opt.name] = map_1[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - } + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + default: + var map_1 = opt.type; + var key = (args[i] || "").toLowerCase(); + i++; + if (ts.hasProperty(map_1, key)) { + options[opt.name] = map_1[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + } + } } } else { @@ -3739,9 +3931,9 @@ var ts; } return output; } - function parseJsonConfigFileContent(json, host, basePath, existingOptions) { + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName) { if (existingOptions === void 0) { existingOptions = {}; } - var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), optionsFromJsonConfigFile = _a.options, errors = _a.errors; + var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath, configFileName), optionsFromJsonConfigFile = _a.options, errors = _a.errors; var options = ts.extend(existingOptions, optionsFromJsonConfigFile); return { options: options, @@ -3760,7 +3952,18 @@ var ts; } else { var filesSeen = {}; - var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; + var exclude = []; + if (json["exclude"] instanceof Array) { + exclude = json["exclude"]; + } + else { + exclude = ["node_modules"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + exclude.push(outDir); + } + } + exclude = ts.map(exclude, ts.normalizeSlashes); var supportedExtensions = ts.getSupportedExtensions(options); ts.Debug.assert(ts.indexOf(supportedExtensions, ".ts") < ts.indexOf(supportedExtensions, ".d.ts"), "Changed priority of extensions to pick"); for (var _i = 0, supportedExtensions_1 = supportedExtensions; _i < supportedExtensions_1.length; _i++) { @@ -3771,6 +3974,9 @@ var ts; if (extension === ".ts" && ts.fileExtensionIs(fileName, ".d.ts")) { continue; } + if (/\.min\.js$/.test(fileName)) { + continue; + } if (extension === ".d.ts" || (options.allowJs && ts.contains(ts.supportedJavascriptExtensions, extension))) { var baseName = fileName.substr(0, fileName.length - extension.length); if (ts.hasProperty(filesSeen, baseName + ".ts") || ts.hasProperty(filesSeen, baseName + ".tsx")) { @@ -3786,9 +3992,12 @@ var ts; } } ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompilerOptionsFromJson(jsonOptions, basePath) { + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var options = {}; var errors = []; + if (configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json") { + options.allowJs = true; + } if (!jsonOptions) { return { options: options, errors: errors }; } @@ -3811,7 +4020,36 @@ var ts; } } if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + switch (typeof value) { + case "string": + value = ts.normalizePath(ts.combinePaths(basePath, value)); + break; + case "object": + var paths = []; + var invalidOptionType = false; + if (!ts.isArray(value)) { + invalidOptionType = true; + } + else { + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + if (typeof element === "string") { + paths.push(ts.normalizePath(ts.combinePaths(basePath, element))); + } + else { + invalidOptionType = true; + break; + } + } + } + if (invalidOptionType) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_should_have_array_of_strings_as_a_value, opt.name)); + } + else { + value = paths; + } + break; + } if (value === "") { value = "."; } @@ -3848,10 +4086,10 @@ var ts; var stringWriters = []; function getSingleLineStringWriter() { if (stringWriters.length === 0) { - var str = ""; - var writeText = function (text) { return str += text; }; + var str_1 = ""; + var writeText = function (text) { return str_1 += text; }; return { - string: function () { return str; }, + string: function () { return str_1; }, writeKeyword: writeText, writeOperator: writeText, writePunctuation: writeText, @@ -3859,10 +4097,10 @@ var ts; writeStringLiteral: writeText, writeParameter: writeText, writeSymbol: writeText, - writeLine: function () { return str += " "; }, + writeLine: function () { return str_1 += " "; }, increaseIndent: function () { }, decreaseIndent: function () { }, - clear: function () { return str = ""; }, + clear: function () { return str_1 = ""; }, trackSymbol: function () { }, reportInaccessibleThisError: function () { } }; @@ -3912,26 +4150,38 @@ var ts; ts.setResolvedModule = setResolvedModule; function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 64) !== 0; + return (node.flags & 268435456) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 128)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || + if (!(node.flags & 536870912)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 67108864) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 64; + node.flags |= 268435456; } - node.parserContextFlags |= 128; + node.flags |= 536870912; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 251) { + while (node && node.kind !== 252) { node = node.parent; } return node; } ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 196: + case 224: + case 203: + case 204: + case 205: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; function getStartPositionOfLine(line, sourceFile) { ts.Debug.assert(line >= 0); return ts.getLineStarts(sourceFile)[line]; @@ -4006,17 +4256,24 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 24576) !== 0 || + return (getCombinedNodeFlags(declaration) & 3072) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 221 && + return node && node.kind === 222 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; + function isBlockScopedContainerTopLevel(node) { + return node.kind === 252 || + node.kind === 222 || + isFunctionLike(node) || + isFunctionBlock(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 2097152); + return !!(module.flags & 131072); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -4024,9 +4281,9 @@ var ts; return false; } switch (node.parent.kind) { - case 251: + case 252: return isExternalModule(node.parent); - case 222: + case 223: return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); } return false; @@ -4039,15 +4296,15 @@ var ts; return current; } switch (current.kind) { - case 251: - case 223: - case 247: - case 221: - case 202: + case 252: + case 224: + case 248: + case 222: case 203: case 204: + case 205: return current; - case 195: + case 196: if (!isFunctionLike(current.parent)) { return current; } @@ -4058,9 +4315,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 214 && + declaration.kind === 215 && declaration.parent && - declaration.parent.kind === 247; + declaration.parent.kind === 248; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -4096,24 +4353,26 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 251: + case 252: 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 214: - case 166: - case 217: - case 189: + case 215: + case 167: case 218: - case 221: - case 220: - case 250: - case 216: - case 176: - case 144: + case 190: case 219: + case 222: + case 221: + case 251: + case 217: + case 177: + case 145: + case 147: + case 148: + case 220: errorNode = node.name; break; } @@ -4135,15 +4394,15 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { - return (file.flags & 4096) !== 0; + return file.isDeclarationFile; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 220 && isConst(node); + return node.kind === 221 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 166 || isBindingPattern(node))) { + while (node && (node.kind === 167 || isBindingPattern(node))) { node = node.parent; } return node; @@ -4151,29 +4410,33 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 214) { + if (node.kind === 215) { node = node.parent; } - if (node && node.kind === 215) { + if (node && node.kind === 216) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 196) { + if (node && node.kind === 197) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 16384); + return !!(getCombinedNodeFlags(node) & 2048); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 8192); + return !!(getCombinedNodeFlags(node) & 1024); } ts.isLet = isLet; + function isSuperCallExpression(n) { + return n.kind === 172 && n.expression.kind === 95; + } + ts.isSuperCallExpression = isSuperCallExpression; function isPrologueDirective(node) { - return node.kind === 198 && node.expression.kind === 9; + return node.kind === 199 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -4189,7 +4452,7 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 139 || node.kind === 138) ? + var commentRanges = (node.kind === 140 || node.kind === 139) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -4203,67 +4466,67 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (151 <= node.kind && node.kind <= 163) { + if (152 <= node.kind && node.kind <= 164) { return true; } switch (node.kind) { case 117: - case 128: - case 130: - case 120: + case 129: case 131: + case 120: + case 132: return true; case 103: - return node.parent.kind !== 180; - case 191: + return node.parent.kind !== 181; + case 192: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 69: - if (node.parent.kind === 136 && node.parent.right === node) { + if (node.parent.kind === 137 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 169 && node.parent.name === node) { + else if (node.parent.kind === 170 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 69 || node.kind === 136 || node.kind === 169, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 136: - case 169: + ts.Debug.assert(node.kind === 69 || node.kind === 137 || node.kind === 170, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 137: + case 170: case 97: var parent_1 = node.parent; - if (parent_1.kind === 155) { + if (parent_1.kind === 156) { return false; } - if (151 <= parent_1.kind && parent_1.kind <= 163) { + if (152 <= parent_1.kind && parent_1.kind <= 164) { return true; } switch (parent_1.kind) { - case 191: + case 192: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 138: - return node === parent_1.constraint; - case 142: - case 141: case 139: - case 214: + return node === parent_1.constraint; + case 143: + case 142: + case 140: + case 215: return node === parent_1.type; - case 216: - case 176: + case 217: case 177: + case 178: + case 146: case 145: case 144: - case 143: - case 146: case 147: - return node === parent_1.type; case 148: + return node === parent_1.type; case 149: case 150: + case 151: return node === parent_1.type; - case 174: + case 175: return node === parent_1.type; - case 171: case 172: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 173: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 174: return false; } } @@ -4274,23 +4537,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 207: + case 208: return visitor(node); - case 223: - case 195: - case 199: + case 224: + case 196: case 200: case 201: case 202: case 203: case 204: - case 208: + case 205: case 209: - case 244: - case 245: case 210: - case 212: - case 247: + case 245: + case 246: + case 211: + case 213: + case 248: return ts.forEachChild(node, traverse); } } @@ -4300,23 +4563,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 187: + case 188: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 220: - case 218: case 221: case 219: - case 217: - case 189: + case 222: + case 220: + case 218: + case 190: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 137) { + if (name_5 && name_5.kind === 138) { traverse(name_5.expression); return; } @@ -4331,14 +4594,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 166: - case 250: - case 139: - case 248: - case 142: - case 141: + case 167: + case 251: + case 140: case 249: - case 214: + case 143: + case 142: + case 250: + case 215: return true; } } @@ -4346,11 +4609,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 146 || node.kind === 147); + return node && (node.kind === 147 || node.kind === 148); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 217 || node.kind === 189); + return node && (node.kind === 218 || node.kind === 190); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -4359,32 +4622,32 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 145: - case 176: - case 216: - case 177: - case 144: - case 143: case 146: + case 177: + case 217: + case 178: + case 145: + case 144: case 147: case 148: case 149: case 150: - case 153: + case 151: case 154: + case 155: return true; } } ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 144: - case 143: case 145: + case 144: case 146: case 147: - case 216: - case 176: + case 148: + case 217: + case 177: return true; } return false; @@ -4392,30 +4655,34 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 202: case 203: case 204: - case 200: + case 205: case 201: + case 202: return true; - case 210: + case 211: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 195 && isFunctionLike(node.parent); + return node && node.kind === 196 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 144 && node.parent.kind === 168; + return node && node.kind === 145 && node.parent.kind === 169; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0; + } + ts.isThisTypePredicate = isThisTypePredicate; function getContainingFunction(node) { while (true) { node = node.parent; @@ -4441,39 +4708,39 @@ var ts; return undefined; } switch (node.kind) { - case 137: + case 138: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 140: - if (node.parent.kind === 139 && isClassElement(node.parent.parent)) { + case 141: + if (node.parent.kind === 140 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 177: + case 178: if (!includeArrowFunctions) { continue; } - case 216: - case 176: - case 221: - case 142: - case 141: - case 144: + case 217: + case 177: + case 222: case 143: + case 142: case 145: + case 144: case 146: case 147: case 148: case 149: case 150: - case 220: - case 251: + case 151: + case 221: + case 252: return node; } } @@ -4486,25 +4753,25 @@ var ts; return node; } switch (node.kind) { - case 137: + case 138: node = node.parent; break; - case 216: - case 176: + case 217: case 177: + case 178: if (!stopOnFunctions) { continue; } - case 142: - case 141: - case 144: case 143: + case 142: case 145: + case 144: case 146: case 147: + case 148: return node; - case 140: - if (node.parent.kind === 139 && isClassElement(node.parent.parent)) { + case 141: + if (node.parent.kind === 140 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -4515,15 +4782,21 @@ var ts; } } ts.getSuperContainer = getSuperContainer; + function isSuperPropertyOrElementAccess(node) { + return (node.kind === 170 + || node.kind === 171) + && node.expression.kind === 95; + } + ts.isSuperPropertyOrElementAccess = isSuperPropertyOrElementAccess; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 152: + case 153: return node.typeName; - case 191: + case 192: return node.expression; case 69: - case 136: + case 137: return node; } } @@ -4531,7 +4804,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 173) { + if (node.kind === 174) { return node.tag; } return node.expression; @@ -4539,21 +4812,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 217: + case 218: return true; - case 142: - return node.parent.kind === 217; - case 146: + case 143: + return node.parent.kind === 218; case 147: - case 144: + case 148: + case 145: return node.body !== undefined - && node.parent.kind === 217; - case 139: + && node.parent.kind === 218; + case 140: return node.parent.body !== undefined - && (node.parent.kind === 145 - || node.parent.kind === 144 - || node.parent.kind === 147) - && node.parent.parent.kind === 217; + && (node.parent.kind === 146 + || node.parent.kind === 145 + || node.parent.kind === 148) + && node.parent.parent.kind === 218; } return false; } @@ -4564,11 +4837,11 @@ var ts; } ts.nodeIsDecorated = nodeIsDecorated; function isPropertyAccessExpression(node) { - return node.kind === 169; + return node.kind === 170; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 170; + return node.kind === 171; } ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { @@ -4578,42 +4851,42 @@ var ts; case 99: case 84: case 10: - case 167: case 168: case 169: case 170: case 171: case 172: case 173: - case 192: case 174: + case 193: case 175: case 176: - case 189: case 177: - case 180: + case 190: case 178: + case 181: case 179: - case 182: + case 180: case 183: case 184: case 185: - case 188: case 186: - case 11: - case 190: - case 236: - case 237: + case 189: case 187: - case 181: + case 11: + case 191: + case 237: + case 238: + case 188: + case 182: return true; - case 136: - while (node.parent.kind === 136) { + case 137: + while (node.parent.kind === 137) { node = node.parent; } - return node.parent.kind === 155; + return node.parent.kind === 156; case 69: - if (node.parent.kind === 155) { + if (node.parent.kind === 156) { return true; } case 8: @@ -4621,47 +4894,47 @@ var ts; case 97: var parent_2 = node.parent; switch (parent_2.kind) { - case 214: - case 139: + case 215: + case 140: + case 143: case 142: - case 141: - case 250: - case 248: - case 166: + case 251: + case 249: + case 167: return parent_2.initializer === node; - case 198: case 199: case 200: case 201: - case 207: + case 202: case 208: case 209: - case 244: - case 211: - case 209: + case 210: + case 245: + case 212: + case 210: return parent_2.expression === node; - case 202: + case 203: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 215) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 216) || forStatement.condition === node || forStatement.incrementor === node; - case 203: case 204: + case 205: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 215) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 216) || forInStatement.expression === node; - case 174: - case 192: - return node === parent_2.expression; + case 175: case 193: return node === parent_2.expression; - case 137: + case 194: return node === parent_2.expression; - case 140: + case 138: + return node === parent_2.expression; + case 141: + case 244: case 243: - case 242: return true; - case 191: + case 192: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4683,7 +4956,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 224 && node.moduleReference.kind === 235; + return node.kind === 225 && node.moduleReference.kind === 236; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4692,7 +4965,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 224 && node.moduleReference.kind !== 235; + return node.kind === 225 && node.moduleReference.kind !== 236; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -4700,23 +4973,23 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.parserContextFlags & 32); + return node && !!(node.flags & 134217728); } ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression) { - return expression.kind === 171 && + function isRequireCall(expression, checkArgumentIsStringLiteral) { + var isRequire = expression.kind === 172 && expression.expression.kind === 69 && expression.expression.text === "require" && - expression.arguments.length === 1 && - expression.arguments[0].kind === 9; + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); } ts.isRequireCall = isRequireCall; function getSpecialPropertyAssignmentKind(expression) { - if (expression.kind !== 184) { + if (expression.kind !== 185) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 169) { + if (expr.operatorToken.kind !== 56 || expr.left.kind !== 170) { return 0; } var lhs = expr.left; @@ -4732,7 +5005,7 @@ var ts; else if (lhs.expression.kind === 97) { return 4; } - else if (lhs.expression.kind === 169) { + else if (lhs.expression.kind === 170) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 69 && innerPropertyAccess.name.text === "prototype") { return 3; @@ -4742,19 +5015,19 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 225) { + if (node.kind === 226) { return node.moduleSpecifier; } - if (node.kind === 224) { + if (node.kind === 225) { var reference = node.moduleReference; - if (reference.kind === 235) { + if (reference.kind === 236) { return reference.expression; } } - if (node.kind === 231) { + if (node.kind === 232) { return node.moduleSpecifier; } - if (node.kind === 221 && node.name.kind === 9) { + if (node.kind === 222 && node.name.kind === 9) { return node.name; } } @@ -4762,13 +5035,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 139: + case 140: + case 145: case 144: - case 143: + case 250: case 249: - case 248: + case 143: case 142: - case 141: return node.questionToken !== undefined; } } @@ -4776,49 +5049,83 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 264 && + return node.kind === 265 && node.parameters.length > 0 && - node.parameters[0].type.kind === 266; + node.parameters[0].type.kind === 267; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind) { - if (node && node.jsDocComment) { - for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.kind === kind) { - return tag; - } + function getJSDocTag(node, kind, checkParentVariableStatement) { + if (!node) { + return undefined; + } + var jsDocComment = getJSDocComment(node, checkParentVariableStatement); + if (!jsDocComment) { + return undefined; + } + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === kind) { + return tag; } } } + function getJSDocComment(node, checkParentVariableStatement) { + if (node.jsDocComment) { + return node.jsDocComment; + } + if (checkParentVariableStatement) { + var isInitializerOfVariableDeclarationInStatement = node.parent.kind === 215 && + node.parent.initializer === node && + node.parent.parent.parent.kind === 197; + var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; + if (variableStatementNode) { + return variableStatementNode.jsDocComment; + } + var parent_3 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_3 && parent_3.parent && + parent_3.kind === 185 && + parent_3.operatorToken.kind === 56 && + parent_3.parent.kind === 199; + if (isSourceOfAssignmentExpressionStatement) { + return parent_3.parent.jsDocComment; + } + var isPropertyAssignmentExpression = parent_3 && parent_3.kind === 249; + if (isPropertyAssignmentExpression) { + return parent_3.jsDocComment; + } + } + return undefined; + } function getJSDocTypeTag(node) { - return getJSDocTag(node, 272); + return getJSDocTag(node, 273, false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 271); + return getJSDocTag(node, 272, true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 273); + return getJSDocTag(node, 274, false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { if (parameter.name && parameter.name.kind === 69) { var parameterName = parameter.name.text; - var docComment = parameter.parent.jsDocComment; - if (docComment) { - return ts.forEach(docComment.tags, function (t) { - if (t.kind === 270) { - var parameterTag = t; + var jsDocComment = getJSDocComment(parameter.parent, true); + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === 271) { + var parameterTag = tag; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { - return t; + return parameterTag; } } - }); + } } } + return undefined; } ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; function hasRestParameter(s) { @@ -4827,13 +5134,13 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { if (node) { - if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 265) { + if (node.flags & 134217728) { + if (node.type && node.type.kind === 266) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 265; + return paramTag.typeExpression.type.kind === 266; } } return node.dotDotDotToken !== undefined; @@ -4854,7 +5161,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 165 || node.kind === 164); + return !!node && (node.kind === 166 || node.kind === 165); } ts.isBindingPattern = isBindingPattern; function isNodeDescendentOf(node, ancestor) { @@ -4868,7 +5175,7 @@ var ts; ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (4 | 4096)) { + if (node.flags & 2 || (node.kind === 252 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -4878,34 +5185,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 177: - case 166: - case 217: - case 189: - case 145: - case 220: - case 250: - case 233: - case 216: - case 176: - case 146: - case 226: - case 224: - case 229: + case 178: + case 167: case 218: - case 144: - case 143: + case 190: + case 146: case 221: - case 227: - case 139: - case 248: - case 142: - case 141: + case 251: + case 234: + case 217: + case 177: case 147: - case 249: + case 227: + case 225: + case 230: case 219: - case 138: - case 214: + case 145: + case 144: + case 222: + case 228: + case 140: + case 249: + case 143: + case 142: + case 148: + case 250: + case 220: + case 139: + case 215: return true; } return false; @@ -4913,25 +5220,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 206: - case 205: - case 213: - case 200: - case 198: - case 197: - case 203: - case 204: - case 202: - case 199: - case 210: case 207: - case 209: - case 211: - case 212: - case 196: + case 206: + case 214: case 201: + case 199: + case 198: + case 204: + case 205: + case 203: + case 200: + case 211: case 208: - case 230: + case 210: + case 212: + case 213: + case 197: + case 202: + case 209: + case 231: return true; default: return false; @@ -4940,13 +5247,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 145: - case 142: - case 144: case 146: - case 147: case 143: - case 150: + case 145: + case 147: + case 148: + case 144: + case 151: return true; default: return false; @@ -4958,7 +5265,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 229 || parent.kind === 233) { + if (parent.kind === 230 || parent.kind === 234) { if (parent.propertyName) { return true; } @@ -4972,40 +5279,40 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 142: - case 141: - case 144: case 143: - case 146: + case 142: + case 145: + case 144: case 147: - case 250: - case 248: - case 169: + case 148: + case 251: + case 249: + case 170: return parent.name === node; - case 136: + case 137: if (parent.right === node) { - while (parent.kind === 136) { + while (parent.kind === 137) { parent = parent.parent; } - return parent.kind === 155; + return parent.kind === 156; } return false; - case 166: - case 229: + case 167: + case 230: return parent.propertyName === node; - case 233: + case 234: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 224 || - node.kind === 226 && !!node.name || - node.kind === 227 || - node.kind === 229 || - node.kind === 233 || - node.kind === 230 && node.expression.kind === 69; + return node.kind === 225 || + node.kind === 227 && !!node.name || + node.kind === 228 || + node.kind === 230 || + node.kind === 234 || + node.kind === 231 && node.expression.kind === 69; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5087,7 +5394,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 <= token && token <= 135; + return 70 <= token && token <= 136; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5107,7 +5414,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 137 && + return name.kind === 138 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -5120,7 +5427,7 @@ var ts; if (name.kind === 69 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 137) { + if (name.kind === 138) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5149,6 +5456,7 @@ var ts; case 112: case 110: case 111: + case 127: case 113: return true; } @@ -5157,18 +5465,18 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 139; + return root.kind === 140; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 166) { + while (node.kind === 167) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 221 || n.kind === 251; + return isFunctionLike(n) || n.kind === 222 || n.kind === 252; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function cloneNode(node, location, flags, parent) { @@ -5201,7 +5509,7 @@ var ts; } ts.cloneEntityName = cloneEntityName; function isQualifiedName(node) { - return node.kind === 136; + return node.kind === 137; } ts.isQualifiedName = isQualifiedName; function nodeIsSynthesized(node) { @@ -5442,9 +5750,9 @@ var ts; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { - return compilerOptions.module ? + return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? 5 : 0; + getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function forEachExpectedEmitFile(host, action, targetSourceFile) { @@ -5462,7 +5770,18 @@ var ts; } } function onSingleFileEmit(host, sourceFile) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, sourceFile.languageVariant === 1 && options.jsx === 1 ? ".jsx" : ".js"); + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); var emitFileNames = { jsFilePath: jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), @@ -5514,7 +5833,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 145 && nodeIsPresent(member.body)) { + if (member.kind === 146 && nodeIsPresent(member.body)) { return member; } }); @@ -5531,10 +5850,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 146) { + if (accessor.kind === 147) { getAccessor = accessor; } - else if (accessor.kind === 147) { + else if (accessor.kind === 148) { setAccessor = accessor; } else { @@ -5543,8 +5862,8 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 146 || member.kind === 147) - && (member.flags & 64) === (accessor.flags & 64)) { + if ((member.kind === 147 || member.kind === 148) + && (member.flags & 32) === (accessor.flags & 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -5554,10 +5873,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 146 && !getAccessor) { + if (member.kind === 147 && !getAccessor) { getAccessor = member; } - if (member.kind === 147 && !setAccessor) { + if (member.kind === 148 && !setAccessor) { setAccessor = member; } } @@ -5612,7 +5931,7 @@ var ts; } if (leadingComments) { var detachedComments = []; - var lastComment; + var lastComment = void 0; for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { var comment = leadingComments_1[_i]; if (lastComment) { @@ -5646,7 +5965,7 @@ var ts; if (text.charCodeAt(comment.pos + 1) === 42) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, comment.pos); var lineCount = lineMap.length; - var firstCommentLineIndent; + var firstCommentLineIndent = void 0; for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { var nextLineStart = (currentLine + 1) === lineCount ? text.length + 1 @@ -5706,16 +6025,17 @@ var ts; } function modifierToFlag(token) { switch (token) { - case 113: return 64; - case 112: return 8; - case 111: return 32; - case 110: return 16; + case 113: return 32; + case 112: return 4; + case 111: return 16; + case 110: return 8; case 115: return 128; - case 82: return 2; - case 122: return 4; - case 74: return 16384; + case 82: return 1; + case 122: return 2; + case 74: return 2048; case 77: return 512; case 118: return 256; + case 127: return 64; } return 0; } @@ -5723,24 +6043,24 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 169: case 170: - case 172: case 171: - case 236: - case 237: case 173: - case 167: - case 175: + case 172: + case 237: + case 238: + case 174: case 168: - case 189: case 176: + case 169: + case 190: + case 177: case 69: case 10: case 8: case 9: case 11: - case 186: + case 187: case 84: case 93: case 97: @@ -5757,7 +6077,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 191 && + return node.kind === 192 && node.parent.token === 83 && isClassLike(node.parent.parent); } @@ -5778,16 +6098,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 136 && node.parent.right === node) || - (node.parent.kind === 169 && node.parent.name === node); + return (node.parent.kind === 137 && node.parent.right === node) || + (node.parent.kind === 170 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 168) { + if (kind === 169) { return expression.properties.length === 0; } - if (kind === 167) { + if (kind === 168) { return expression.elements.length === 0; } return false; @@ -6031,9 +6351,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 138) { + if (d && d.kind === 139) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 218) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 219) { return current; } } @@ -6041,7 +6361,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return node.flags & 56 && node.parent.kind === 145 && ts.isClassLike(node.parent.parent); + return node.flags & 28 && node.parent.kind === 146 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; })(ts || (ts = {})); @@ -6051,7 +6371,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 251) { + if (kind === 252) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else { @@ -6087,26 +6407,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 136: + case 137: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 138: + case 139: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 249: + case 250: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 139: + case 140: + case 143: case 142: - case 141: - case 248: - case 214: - case 166: + case 249: + case 215: + case 167: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6115,24 +6435,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 153: case 154: - case 148: + case 155: case 149: case 150: + case 151: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 144: - case 143: case 145: + case 144: case 146: case 147: - case 176: - case 216: + case 148: case 177: + case 217: + case 178: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6143,160 +6463,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 152: + case 153: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 151: + case 152: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 155: - return visitNode(cbNode, node.exprName); case 156: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 157: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 158: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 159: + return visitNodes(cbNodes, node.elementTypes); case 160: - return visitNodes(cbNodes, node.types); case 161: + return visitNodes(cbNodes, node.types); + case 162: return visitNode(cbNode, node.type); - case 164: case 165: - return visitNodes(cbNodes, node.elements); - case 167: + case 166: return visitNodes(cbNodes, node.elements); case 168: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 169: + return visitNodes(cbNodes, node.properties); + case 170: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 170: + case 171: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 171: case 172: + case 173: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 173: + case 174: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 174: + case 175: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 175: - return visitNode(cbNode, node.expression); - case 178: + case 176: return visitNode(cbNode, node.expression); case 179: return visitNode(cbNode, node.expression); case 180: return visitNode(cbNode, node.expression); - case 182: - return visitNode(cbNode, node.operand); - case 187: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 181: return visitNode(cbNode, node.expression); case 183: return visitNode(cbNode, node.operand); + case 188: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 182: + return visitNode(cbNode, node.expression); case 184: + return visitNode(cbNode, node.operand); + case 185: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 192: + case 193: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 185: + case 186: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 188: + case 189: return visitNode(cbNode, node.expression); - case 195: - case 222: + case 196: + case 223: return visitNodes(cbNodes, node.statements); - case 251: + case 252: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 196: + case 197: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 215: + case 216: return visitNodes(cbNodes, node.declarations); - case 198: - return visitNode(cbNode, node.expression); case 199: + return visitNode(cbNode, node.expression); + case 200: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 200: + case 201: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 201: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 202: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 203: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 204: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 205: - case 206: - return visitNode(cbNode, node.label); - case 207: - return visitNode(cbNode, node.expression); - case 208: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 206: + case 207: + return visitNode(cbNode, node.label); + case 208: + return visitNode(cbNode, node.expression); case 209: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 223: + case 224: return visitNodes(cbNodes, node.clauses); - case 244: + case 245: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 245: + case 246: return visitNodes(cbNodes, node.statements); - case 210: + case 211: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 211: - return visitNode(cbNode, node.expression); case 212: + return visitNode(cbNode, node.expression); + case 213: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 247: + case 248: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 140: + case 141: return visitNode(cbNode, node.expression); - case 217: - case 189: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 218: + case 190: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -6308,137 +6621,160 @@ 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 220: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 250: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 221: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 251: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 222: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 226: + case 227: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 227: - return visitNode(cbNode, node.name); case 228: - case 232: + return visitNode(cbNode, node.name); + case 229: + case 233: return visitNodes(cbNodes, node.elements); - case 231: + case 232: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 229: - case 233: + case 230: + case 234: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 230: + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 186: + case 187: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 193: + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 137: + case 138: return visitNode(cbNode, node.expression); - case 246: + case 247: return visitNodes(cbNodes, node.types); - case 191: + case 192: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 235: - return visitNode(cbNode, node.expression); - case 234: - return visitNodes(cbNodes, node.decorators); case 236: + return visitNode(cbNode, node.expression); + case 235: + return visitNodes(cbNodes, node.decorators); + case 237: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 237: case 238: + case 239: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 241: + case 242: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 242: - return visitNode(cbNode, node.expression); case 243: return visitNode(cbNode, node.expression); - case 240: + case 244: + return visitNode(cbNode, node.expression); + case 241: return visitNode(cbNode, node.tagName); - case 252: + case 253: return visitNode(cbNode, node.type); - case 256: - return visitNodes(cbNodes, node.types); case 257: return visitNodes(cbNodes, node.types); - case 255: + case 258: + return visitNodes(cbNodes, node.types); + case 256: return visitNode(cbNode, node.elementType); + case 260: + return visitNode(cbNode, node.type); case 259: return visitNode(cbNode, node.type); - case 258: - return visitNode(cbNode, node.type); - case 260: + case 261: return visitNodes(cbNodes, node.members); - case 262: + case 263: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 263: - return visitNode(cbNode, node.type); case 264: + return visitNode(cbNode, node.type); + case 265: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 265: - return visitNode(cbNode, node.type); case 266: return visitNode(cbNode, node.type); case 267: return visitNode(cbNode, node.type); - case 261: + case 268: + return visitNode(cbNode, node.type); + case 262: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 268: + case 269: return visitNodes(cbNodes, node.tags); - case 270: + case 271: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 271: - return visitNode(cbNode, node.typeExpression); case 272: return visitNode(cbNode, node.typeExpression); case 273: + return visitNode(cbNode, node.typeExpression); + case 274: return visitNodes(cbNodes, node.typeParameters); } } ts.forEachChild = forEachChild; - function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { + function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { 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, undefined, setParentNodes, scriptKind); ts.parseTime += new Date().getTime() - start; return result; } ts.createSourceFile = createSourceFile; + function getScriptKindFromFileName(fileName) { + var ext = fileName.substr(fileName.lastIndexOf(".")); + switch (ext.toLowerCase()) { + case ".js": + return 1; + case ".jsx": + return 2; + case ".ts": + return 3; + case ".tsx": + return 4; + default: + return 3; + } + } + ts.getScriptKindFromFileName = getScriptKindFromFileName; function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); } @@ -6454,7 +6790,7 @@ var ts; var Parser; (function (Parser) { var scanner = ts.createScanner(2, true); - var disallowInAndDecoratorContext = 1 | 4; + var disallowInAndDecoratorContext = 4194304 | 16777216; var NodeConstructor; var SourceFileConstructor; var sourceFile; @@ -6468,18 +6804,18 @@ var ts; var parsingContext; var contextFlags; var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; - initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); - var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); + function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName); + initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function getLanguageVariant(fileName) { - return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx") ? 1 : 0; + function getLanguageVariant(scriptKind) { + return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } - function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor(); sourceText = _sourceText; @@ -6489,12 +6825,12 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = isJavaScriptFile ? 32 : 0; + contextFlags = scriptKind === 1 || scriptKind === 2 ? 134217728 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(getLanguageVariant(fileName)); + scanner.setLanguageVariant(getLanguageVariant(scriptKind)); } function clearState() { scanner.setText(""); @@ -6505,11 +6841,9 @@ var ts; syntaxCursor = undefined; sourceText = undefined; } - function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { - sourceFile = createSourceFile(fileName, languageVersion); - if (contextFlags & 32) { - sourceFile.parserContextFlags = 32; - } + function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { + sourceFile = createSourceFile(fileName, languageVersion, scriptKind); + sourceFile.flags = contextFlags; token = nextToken(); processReferenceComments(sourceFile); sourceFile.statements = parseList(0, parseStatement); @@ -6523,35 +6857,22 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - if (ts.isSourceFileJavaScript(sourceFile)) { - addJSDocComments(); - } return sourceFile; } - function addJSDocComments() { - forEachChild(sourceFile, visit); - return; - function visit(node) { - switch (node.kind) { - case 196: - case 216: - case 139: - addJSDocComment(node); - } - forEachChild(node, visit); - } - } function addJSDocComment(node) { - var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (jsDocComment) { - node.jsDocComment = jsDocComment; + if (contextFlags & 134217728) { + var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (jsDocComment) { + node.jsDocComment = jsDocComment; + } } } } + return node; } function fixupParentReferences(sourceFile) { var parent = sourceFile; @@ -6568,15 +6889,16 @@ var ts; } } Parser.fixupParentReferences = fixupParentReferences; - function createSourceFile(fileName, languageVersion) { - var sourceFile = new SourceFileConstructor(251, 0, sourceText.length); + function createSourceFile(fileName, languageVersion, scriptKind) { + var sourceFile = new SourceFileConstructor(252, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 : 0; - sourceFile.languageVariant = getLanguageVariant(sourceFile.fileName); + sourceFile.languageVariant = getLanguageVariant(scriptKind); + sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts"); + sourceFile.scriptKind = scriptKind; return sourceFile; } function setContextFlag(val, flag) { @@ -6588,16 +6910,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 1); + setContextFlag(val, 4194304); } function setYieldContext(val) { - setContextFlag(val, 2); + setContextFlag(val, 8388608); } function setDecoratorContext(val) { - setContextFlag(val, 4); + setContextFlag(val, 16777216); } function setAwaitContext(val) { - setContextFlag(val, 8); + setContextFlag(val, 33554432); } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; @@ -6620,40 +6942,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(1, func); + return doOutsideOfContext(4194304, func); } function disallowInAnd(func) { - return doInsideOfContext(1, func); + return doInsideOfContext(4194304, func); } function doInYieldContext(func) { - return doInsideOfContext(2, func); + return doInsideOfContext(8388608, func); } function doInDecoratorContext(func) { - return doInsideOfContext(4, func); + return doInsideOfContext(16777216, func); } function doInAwaitContext(func) { - return doInsideOfContext(8, func); + return doInsideOfContext(33554432, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(8, func); + return doOutsideOfContext(33554432, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(2 | 8, func); + return doInsideOfContext(8388608 | 33554432, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(2); + return inContext(8388608); } function inDisallowInContext() { - return inContext(1); + return inContext(4194304); } function inDecoratorContext() { - return inContext(4); + return inContext(16777216); } function inAwaitContext() { - return inContext(8); + return inContext(33554432); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -6794,11 +7116,11 @@ var ts; function finishNode(node, end) { node.end = end === undefined ? scanner.getStartPos() : end; if (contextFlags) { - node.parserContextFlags = contextFlags; + node.flags |= contextFlags; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16; + node.flags |= 67108864; } return node; } @@ -6860,7 +7182,7 @@ var ts; return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(137); + var node = createNode(138); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); @@ -6922,7 +7244,7 @@ var ts; case 2: return token === 71 || token === 77; case 4: - return isStartOfTypeMember(); + return lookAhead(isTypeMemberStart); case 5: return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); case 6: @@ -7112,7 +7434,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 31; + var nodeContextFlags = node.flags & 62914560; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -7159,14 +7481,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 145: - case 150: case 146: + case 151: case 147: - case 142: - case 194: + case 148: + case 143: + case 195: return true; - case 144: + case 145: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 69 && methodDeclaration.name.originalKeywordKind === 121; @@ -7178,8 +7500,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 244: case 245: + case 246: return true; } } @@ -7188,65 +7510,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 216: + case 217: + case 197: case 196: - case 195: + case 200: case 199: - case 198: - case 211: + case 212: + case 208: + case 210: case 207: - case 209: case 206: + case 204: case 205: case 203: - case 204: case 202: - case 201: - case 208: - case 197: - case 212: - case 210: - case 200: + case 209: + case 198: case 213: + case 211: + case 201: + case 214: + case 226: case 225: - case 224: + case 232: case 231: - case 230: - case 221: - case 217: + case 222: case 218: - case 220: case 219: + case 221: + case 220: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 250; + return node.kind === 251; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 149: - case 143: case 150: - case 141: - case 148: + case 144: + case 151: + case 142: + case 149: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 214) { + if (node.kind !== 215) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 139) { + if (node.kind !== 140) { return false; } var parameter = node; @@ -7291,7 +7613,7 @@ var ts; } } ; - function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimeter) { + function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; @@ -7309,7 +7631,7 @@ var ts; break; } parseExpected(24); - if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token === 23 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -7346,7 +7668,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21)) { - var node = createNode(136, entity.pos); + var node = createNode(137, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -7363,7 +7685,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(186); + var template = createNode(187); template.head = parseTemplateLiteralFragment(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; @@ -7376,7 +7698,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(193); + var span = createNode(194); span.expression = allowInAnd(parseExpression); var literal; if (token === 16) { @@ -7390,7 +7712,7 @@ var ts; return finishNode(span); } function parseStringLiteralTypeNode() { - return parseLiteralLikeNode(163, true); + return parseLiteralLikeNode(164, true); } function parseLiteralNode(internName) { return parseLiteralLikeNode(token, internName); @@ -7414,39 +7736,39 @@ var ts; if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 32768; + node.isOctalLiteral = true; } return node; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(152, typeName.pos); + var node = createNode(153, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } - function parseTypePredicate(lhs) { + function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(151, lhs.pos); + var node = createNode(152, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(162); + var node = createNode(163); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(155); + var node = createNode(156); parseExpected(101); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(138); + var node = createNode(139); node.name = parseIdentifier(); if (parseOptional(83)) { if (isStartOfType() || !isStartOfExpression()) { @@ -7479,7 +7801,7 @@ var ts; } } function parseParameter() { - var node = createNode(139); + var node = createNode(140); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22); @@ -7490,7 +7812,7 @@ var ts; node.questionToken = parseOptionalToken(53); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseBindingElementInitializer(inParameter) { return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); @@ -7534,7 +7856,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 149) { + if (kind === 150) { parseExpected(92); } fillSignature(54, false, false, false, node); @@ -7574,7 +7896,7 @@ var ts; return token === 54 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(150, fullStart); + var node = createNode(151, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16, parseParameter, 19, 20); @@ -7582,12 +7904,12 @@ var ts; parseTypeMemberSemicolon(); return finishNode(node); } - function parsePropertyOrMethodSignature() { - var fullStart = scanner.getStartPos(); + function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); var questionToken = parseOptionalToken(53); if (token === 17 || token === 25) { - var method = createNode(143, fullStart); + var method = createNode(144, fullStart); + setModifiers(method, modifiers); method.name = name; method.questionToken = questionToken; fillSignature(54, false, false, false, method); @@ -7595,7 +7917,8 @@ var ts; return finishNode(method); } else { - var property = createNode(141, fullStart); + var property = createNode(142, fullStart); + setModifiers(property, modifiers); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7606,78 +7929,51 @@ var ts; return finishNode(property); } } - function isStartOfTypeMember() { - switch (token) { - case 17: - case 25: - case 19: - return true; - default: - if (ts.isModifierKind(token)) { - var result = lookAhead(isStartOfIndexSignatureDeclaration); - if (result) { - return result; - } - } - return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); + function isTypeMemberStart() { + var idToken; + if (token === 17 || token === 25) { + return true; } - } - function isStartOfIndexSignatureDeclaration() { while (ts.isModifierKind(token)) { + idToken = token; nextToken(); } - return isIndexSignature(); - } - function isTypeMemberWithLiteralPropertyName() { - nextToken(); - return token === 17 || - token === 25 || - token === 53 || - token === 54 || - canParseSemicolon(); + if (token === 19) { + return true; + } + if (isLiteralPropertyName()) { + idToken = token; + nextToken(); + } + if (idToken) { + return token === 17 || + token === 25 || + token === 53 || + token === 54 || + canParseSemicolon(); + } + return false; } function parseTypeMember() { - switch (token) { - case 17: - case 25: - return parseSignatureMember(148); - case 19: - return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) - : parsePropertyOrMethodSignature(); - case 92: - if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(149); - } - case 9: - case 8: - return parsePropertyOrMethodSignature(); - default: - if (ts.isModifierKind(token)) { - var result = tryParse(parseIndexSignatureWithModifiers); - if (result) { - return result; - } - } - if (ts.tokenIsIdentifierOrKeyword(token)) { - return parsePropertyOrMethodSignature(); - } + if (token === 17 || token === 25) { + return parseSignatureMember(149); } - } - function parseIndexSignatureWithModifiers() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); + if (token === 92 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(150); + } + var fullStart = getNodePos(); var modifiers = parseModifiers(); - return isIndexSignature() - ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) - : undefined; + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, undefined, modifiers); + } + return parsePropertyOrMethodSignature(fullStart, modifiers); } function isStartOfConstructSignature() { nextToken(); return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(156); + var node = createNode(157); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -7693,12 +7989,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(158); + var node = createNode(159); node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(161); + var node = createNode(162); parseExpected(17); node.type = parseType(); parseExpected(18); @@ -7706,7 +8002,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 154) { + if (kind === 155) { parseExpected(92); } fillSignature(34, false, false, false, node); @@ -7719,10 +8015,10 @@ var ts; function parseNonArrayType() { switch (token) { case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -7732,7 +8028,7 @@ var ts; case 97: { var thisKeyword = parseThisTypeNode(); if (token === 124 && !scanner.hasPrecedingLineBreak()) { - return parseTypePredicate(thisKeyword); + return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; @@ -7753,10 +8049,10 @@ var ts; function isStartOfType() { switch (token) { case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: case 103: case 97: case 101: @@ -7780,7 +8076,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { parseExpected(20); - var node = createNode(157, type.pos); + var node = createNode(158, type.pos); node.elementType = type; type = finishNode(node); } @@ -7802,10 +8098,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(160, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(161, parseArrayTypeOrHigher, 46); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(159, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(160, parseIntersectionTypeOrHigher, 47); } function isStartOfFunctionType() { if (token === 25) { @@ -7813,16 +8109,29 @@ var ts; } return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); } + function skipParameterStart() { + if (ts.isModifierKind(token)) { + parseModifiers(); + } + if (isIdentifier()) { + nextToken(); + return true; + } + if (token === 19 || token === 15) { + var previousErrorCount = parseDiagnostics.length; + parseIdentifierOrPattern(); + return previousErrorCount === parseDiagnostics.length; + } + return false; + } function isUnambiguouslyStartOfFunctionType() { nextToken(); if (token === 18 || token === 22) { return true; } - if (isIdentifier() || ts.isModifierKind(token)) { - nextToken(); + if (skipParameterStart()) { if (token === 54 || token === 24 || - token === 53 || token === 56 || - isIdentifier() || ts.isModifierKind(token)) { + token === 53 || token === 56) { return true; } if (token === 18) { @@ -7838,7 +8147,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(151, typePredicateVariable.pos); + var node = createNode(152, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -7855,14 +8164,14 @@ var ts; } } function parseType() { - return doOutsideOfContext(10, parseTypeWorker); + return doOutsideOfContext(41943040, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(153); + return parseFunctionOrConstructorType(154); } if (token === 92) { - return parseFunctionOrConstructorType(154); + return parseFunctionOrConstructorType(155); } return parseUnionTypeOrHigher(); } @@ -7981,7 +8290,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(187); + var node = createNode(188); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token === 37 || isStartOfExpression())) { @@ -7995,8 +8304,8 @@ var ts; } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(177, identifier.pos); - var parameter = createNode(139, identifier.pos); + var node = createNode(178, identifier.pos); + var parameter = createNode(140, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -8107,7 +8416,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(177); + var node = createNode(178); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 256); fillSignature(54, false, isAsync, !allowAmbiguity, node); @@ -8139,7 +8448,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(185, leftOperand.pos); + var node = createNode(186, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -8152,7 +8461,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 135; + return t === 90 || t === 136; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -8230,43 +8539,43 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(184, left.pos); + var node = createNode(185, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(192, left.pos); + var node = createNode(193, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(182); + var node = createNode(183); node.operator = token; nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(178); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(179); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(180); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(181); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token === 119) { if (inAwaitContext()) { @@ -8277,7 +8586,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -8296,7 +8605,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token === 38) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 174) { + if (simpleUnaryExpression.kind === 175) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -8344,7 +8653,7 @@ var ts; } function parseIncrementExpression() { if (token === 41 || token === 42) { - var node = createNode(182); + var node = createNode(183); node.operator = token; nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -8356,7 +8665,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 41 || token === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(183, expression.pos); + var node = createNode(184, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -8379,7 +8688,7 @@ var ts; if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(169, expression.pos); + var node = createNode(170, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -8398,8 +8707,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 238) { - var node = createNode(236, opening.pos); + if (opening.kind === 239) { + var node = createNode(237, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -8409,14 +8718,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 237); + ts.Debug.assert(opening.kind === 238); result = opening; } if (inExpressionContext && token === 25) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(184, result.pos); + var badNode = createNode(185, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -8428,13 +8737,13 @@ var ts; return result; } function parseJsxText() { - var node = createNode(239, scanner.getStartPos()); + var node = createNode(240, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 239: + case 240: return parseJsxText(); case 15: return parseJsxExpression(false); @@ -8470,7 +8779,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token === 27) { - node = createNode(238, fullStart); + node = createNode(239, fullStart); scanJsxText(); } else { @@ -8482,7 +8791,7 @@ var ts; parseExpected(27, undefined, false); scanJsxText(); } - node = createNode(237, fullStart); + node = createNode(238, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -8493,7 +8802,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(136, elementName.pos); + var node = createNode(137, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -8501,7 +8810,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(243); + var node = createNode(244); parseExpected(15); if (token !== 16) { node.expression = parseAssignmentExpressionOrHigher(); @@ -8520,7 +8829,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(241); + var node = createNode(242); node.name = parseIdentifierName(); if (parseOptional(56)) { switch (token) { @@ -8535,7 +8844,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(242); + var node = createNode(243); parseExpected(15); parseExpected(22); node.expression = parseExpression(); @@ -8543,7 +8852,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(240); + var node = createNode(241); parseExpected(26); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -8556,7 +8865,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(174); + var node = createNode(175); parseExpected(25); node.type = parseType(); parseExpected(27); @@ -8567,7 +8876,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(169, expression.pos); + var propertyAccess = createNode(170, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -8575,7 +8884,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(170, expression.pos); + var indexedAccess = createNode(171, expression.pos); indexedAccess.expression = expression; if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -8589,7 +8898,7 @@ var ts; continue; } if (token === 11 || token === 12) { - var tagExpression = createNode(173, expression.pos); + var tagExpression = createNode(174, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 ? parseLiteralNode() @@ -8608,7 +8917,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(171, expression.pos); + var callExpr = createNode(172, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -8616,7 +8925,7 @@ var ts; continue; } else if (token === 17) { - var callExpr = createNode(171, expression.pos); + var callExpr = createNode(172, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -8711,42 +9020,43 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(175); + var node = createNode(176); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(188); + var node = createNode(189); parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 ? parseSpreadElement() : - token === 24 ? createNode(190) : + token === 24 ? createNode(191) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(167); + var node = createNode(168); parseExpected(19); - if (scanner.hasPrecedingLineBreak()) - node.flags |= 1024; + if (scanner.hasPrecedingLineBreak()) { + node.multiLine = true; + } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); parseExpected(20); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(123)) { - return parseAccessorDeclaration(146, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(129)) { return parseAccessorDeclaration(147, fullStart, decorators, modifiers); } + else if (parseContextualModifier(130)) { + return parseAccessorDeclaration(148, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -8766,7 +9076,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 || token === 16 || token === 56); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(249, fullStart); + var shorthandDeclaration = createNode(250, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(56); @@ -8774,23 +9084,23 @@ var ts; shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } - return finishNode(shorthandDeclaration); + return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(248, fullStart); + var propertyAssignment = createNode(249, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(54); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); + return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(168); + var node = createNode(169); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 1024; + node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(16); @@ -8801,7 +9111,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(176); + var node = createNode(177); setModifiers(node, parseModifiers()); parseExpected(87); node.asteriskToken = parseOptionalToken(37); @@ -8817,13 +9127,13 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(true); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(172); + var node = createNode(173); parseExpected(92); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -8833,7 +9143,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(195); + var node = createNode(196); if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -8861,12 +9171,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(197); + var node = createNode(198); parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(199); + var node = createNode(200); parseExpected(88); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8876,7 +9186,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(200); + var node = createNode(201); parseExpected(79); node.statement = parseStatement(); parseExpected(104); @@ -8887,7 +9197,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(201); + var node = createNode(202); parseExpected(104); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8910,21 +9220,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(90)) { - var forInStatement = createNode(203, pos); + var forInStatement = createNode(204, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(135)) { - var forOfStatement = createNode(204, pos); + else if (parseOptional(136)) { + var forOfStatement = createNode(205, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(202, pos); + var forStatement = createNode(203, pos); forStatement.initializer = initializer; parseExpected(23); if (token !== 23 && token !== 18) { @@ -8942,7 +9252,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 206 ? 70 : 75); + parseExpected(kind === 207 ? 70 : 75); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8950,7 +9260,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(207); + var node = createNode(208); parseExpected(94); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -8959,7 +9269,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(208); + var node = createNode(209); parseExpected(105); parseExpected(17); node.expression = allowInAnd(parseExpression); @@ -8968,7 +9278,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(244); + var node = createNode(245); parseExpected(71); node.expression = allowInAnd(parseExpression); parseExpected(54); @@ -8976,7 +9286,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(245); + var node = createNode(246); parseExpected(77); parseExpected(54); node.statements = parseList(3, parseStatement); @@ -8986,12 +9296,12 @@ var ts; return token === 71 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(209); + var node = createNode(210); parseExpected(96); parseExpected(17); node.expression = allowInAnd(parseExpression); parseExpected(18); - var caseBlock = createNode(223, scanner.getStartPos()); + var caseBlock = createNode(224, scanner.getStartPos()); parseExpected(15); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(16); @@ -8999,14 +9309,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(211); + var node = createNode(212); parseExpected(98); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(212); + var node = createNode(213); parseExpected(100); node.tryBlock = parseBlock(false); node.catchClause = token === 72 ? parseCatchClause() : undefined; @@ -9017,7 +9327,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(247); + var result = createNode(248); parseExpected(72); if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); @@ -9027,7 +9337,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(213); + var node = createNode(214); parseExpected(76); parseSemicolon(); return finishNode(node); @@ -9036,16 +9346,16 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(210, fullStart); + var labeledStatement = createNode(211, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); + return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(198, fullStart); + var expressionStatement = createNode(199, fullStart); expressionStatement.expression = expression; parseSemicolon(); - return finishNode(expressionStatement); + return addJSDocComment(finishNode(expressionStatement)); } } function nextTokenIsIdentifierOrKeywordOnSameLine() { @@ -9071,7 +9381,7 @@ var ts; case 81: return true; case 107: - case 132: + case 133: return nextTokenIsIdentifierOnSameLine(); case 125: case 126: @@ -9082,12 +9392,13 @@ var ts; case 110: case 111: case 112: + case 127: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 134: + case 135: return nextToken() === 15; case 89: nextToken(); @@ -9145,13 +9456,14 @@ var ts; case 107: case 125: case 126: - case 132: - case 134: + case 133: + case 135: return true; case 112: case 110: case 111: case 113: + case 127: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -9190,9 +9502,9 @@ var ts; case 86: return parseForOrForInOrForOfStatement(); case 75: - return parseBreakOrContinueStatement(205); - case 70: return parseBreakOrContinueStatement(206); + case 70: + return parseBreakOrContinueStatement(207); case 94: return parseReturnStatement(); case 105: @@ -9211,7 +9523,7 @@ var ts; return parseDeclaration(); case 118: case 107: - case 132: + case 133: case 125: case 126: case 122: @@ -9224,7 +9536,8 @@ var ts; case 112: case 115: case 113: - case 134: + case 127: + case 135: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -9247,11 +9560,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 107: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 132: + case 133: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 81: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 134: + case 135: case 125: case 126: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -9264,7 +9577,7 @@ var ts; parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(234, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(235, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -9285,16 +9598,16 @@ var ts; } function parseArrayBindingElement() { if (token === 24) { - return createNode(190); + return createNode(191); } - var node = createNode(166); + var node = createNode(167); node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(166); + var node = createNode(167); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 54) { @@ -9309,14 +9622,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(164); + var node = createNode(165); parseExpected(15); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(165); + var node = createNode(166); parseExpected(19); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(20); @@ -9335,7 +9648,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(214); + var node = createNode(215); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -9344,21 +9657,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(215); + var node = createNode(216); switch (token) { case 102: break; case 108: - node.flags |= 8192; + node.flags |= 1024; break; case 74: - node.flags |= 16384; + node.flags |= 2048; break; default: ts.Debug.fail(); } nextToken(); - if (token === 135 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 136 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -9373,15 +9686,15 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(196, fullStart); + var node = createNode(197, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216, fullStart); + var node = createNode(217, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(87); @@ -9391,19 +9704,19 @@ var ts; var isAsync = !!(node.flags & 256); fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(145, pos); + var node = createNode(146, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(121); fillSignature(54, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(144, fullStart); + var method = createNode(145, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -9413,18 +9726,18 @@ var ts; var isAsync = !!(method.flags & 256); fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); + return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(142, fullStart); + var property = createNode(143, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = modifiers && modifiers.flags & 64 + property.initializer = modifiers && modifiers.flags & 32 ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(2 | 1, parseNonParameterInitializer); + : doOutsideOfContext(8388608 | 4194304, parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } @@ -9457,6 +9770,7 @@ var ts; case 110: case 111: case 113: + case 127: return true; default: return false; @@ -9485,7 +9799,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 129 || idToken === 123) { + if (!ts.isKeyword(idToken) || idToken === 130 || idToken === 123) { return true; } switch (token) { @@ -9512,7 +9826,7 @@ var ts; decorators = []; decorators.pos = decoratorStart; } - var decorator = createNode(140, decoratorStart); + var decorator = createNode(141, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -9568,7 +9882,7 @@ var ts; } function parseClassElement() { if (token === 23) { - var result = createNode(194); + var result = createNode(195); nextToken(); return finishNode(result); } @@ -9599,10 +9913,10 @@ var ts; ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 189); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 190); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 217); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 218); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -9637,7 +9951,7 @@ var ts; } function parseHeritageClause() { if (token === 83 || token === 106) { - var node = createNode(246); + var node = createNode(247); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -9646,7 +9960,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(191); + var node = createNode(192); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25) { node.typeArguments = parseBracketedList(18, parseType, 25, 27); @@ -9660,7 +9974,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218, fullStart); + var node = createNode(219, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(107); @@ -9671,10 +9985,10 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(219, fullStart); + var node = createNode(220, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(132); + parseExpected(133); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(56); @@ -9683,13 +9997,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNode(250, scanner.getStartPos()); + var node = createNode(251, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(81); @@ -9704,7 +10018,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(222, scanner.getStartPos()); + var node = createNode(223, scanner.getStartPos()); if (parseExpected(15)) { node.statements = parseList(1, parseStatement); parseExpected(16); @@ -9715,24 +10029,24 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(221, fullStart); - var namespaceFlag = flags & 65536; + var node = createNode(222, fullStart); + var namespaceFlag = flags & 4096; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 2 | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221, fullStart); + var node = createNode(222, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (token === 134) { + if (token === 135) { node.name = parseIdentifier(); - node.flags |= 2097152; + node.flags |= 131072; } else { node.name = parseLiteralNode(true); @@ -9742,11 +10056,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (token === 134) { + if (token === 135) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(126)) { - flags |= 65536; + flags |= 4096; } else { parseExpected(125); @@ -9757,7 +10071,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 127 && + return token === 128 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -9772,8 +10086,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 && token !== 133) { - var importEqualsDeclaration = createNode(224, fullStart); + if (token !== 24 && token !== 134) { + var importEqualsDeclaration = createNode(225, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -9783,27 +10097,27 @@ var ts; return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(225, fullStart); + var importDeclaration = createNode(226, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || token === 37 || token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(133); + parseExpected(134); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(226, fullStart); + var importClause = createNode(227, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(24)) { - importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(228); + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(229); } return finishNode(importClause); } @@ -9813,8 +10127,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(235); - parseExpected(127); + var node = createNode(236); + parseExpected(128); parseExpected(17); node.expression = parseModuleSpecifier(); parseExpected(18); @@ -9831,7 +10145,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(227); + var namespaceImport = createNode(228); parseExpected(37); parseExpected(116); namespaceImport.name = parseIdentifier(); @@ -9839,14 +10153,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 228 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 229 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(233); + return parseImportOrExportSpecifier(234); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(229); + return parseImportOrExportSpecifier(230); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9865,23 +10179,23 @@ var ts; else { node.name = identifierName; } - if (kind === 229 && checkIdentifierIsKeyword) { + if (kind === 230 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37)) { - parseExpected(133); + parseExpected(134); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(232); - if (token === 133 || (token === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(133); + node.exportClause = parseNamedImportsOrExports(233); + if (token === 134 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(134); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9889,7 +10203,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(56)) { @@ -9960,11 +10274,11 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 2 - || node.kind === 224 && node.moduleReference.kind === 235 - || node.kind === 225 - || node.kind === 230 + return node.flags & 1 + || node.kind === 225 && node.moduleReference.kind === 236 + || node.kind === 226 || node.kind === 231 + || node.kind === 232 ? node : undefined; }); @@ -9989,17 +10303,17 @@ var ts; } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, true, undefined); - var jsDocTypeExpression = parseJSDocTypeExpression(start, length); + initializeState("file.js", content, 2, undefined, 1); + scanner.setText(content, start, length); + token = scanner.scan(); + var jsDocTypeExpression = parseJSDocTypeExpression(); var diagnostics = parseDiagnostics; clearState(); return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - function parseJSDocTypeExpression(start, length) { - scanner.setText(sourceText, start, length); - token = nextToken(); - var result = createNode(252); + function parseJSDocTypeExpression() { + var result = createNode(253, scanner.getTokenPos()); parseExpected(15); result.type = parseJSDocTopLevelType(); parseExpected(16); @@ -10010,12 +10324,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 47) { - var unionType = createNode(256, type.pos); + var unionType = createNode(257, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 56) { - var optionalType = createNode(263, type.pos); + var optionalType = createNode(264, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -10026,20 +10340,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19) { - var arrayType = createNode(255, type.pos); + var arrayType = createNode(256, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20); type = finishNode(arrayType); } else if (token === 53) { - var nullableType = createNode(258, type.pos); + var nullableType = createNode(259, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 49) { - var nonNullableType = createNode(259, type.pos); + var nonNullableType = createNode(260, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -10073,37 +10387,37 @@ var ts; case 97: return parseJSDocThisType(); case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: case 103: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(267); + var result = createNode(268); nextToken(); parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(266); + var result = createNode(267); nextToken(); parseExpected(54); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(265); + var result = createNode(266); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(264); + var result = createNode(265); nextToken(); parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); @@ -10116,20 +10430,28 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(139); + var parameter = createNode(140); parameter.type = parseJSDocType(); + if (parseOptional(56)) { + parameter.questionToken = createNode(56); + } return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(262); + var result = createNode(263); result.name = parseSimplePropertyName(); - while (parseOptional(21)) { - if (token === 25) { - result.typeArguments = parseTypeArguments(); - break; - } - else { - result.name = parseQualifiedName(result.name); + if (token === 25) { + result.typeArguments = parseTypeArguments(); + } + else { + while (parseOptional(21)) { + if (token === 25) { + result.typeArguments = parseTypeArguments(); + break; + } + else { + result.name = parseQualifiedName(result.name); + } } } return finishNode(result); @@ -10150,13 +10472,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(136, left.pos); + var result = createNode(137, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(260); + var result = createNode(261); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -10164,7 +10486,7 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(261); + var result = createNode(262); result.name = parseSimplePropertyName(); if (token === 54) { nextToken(); @@ -10173,13 +10495,13 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(257); + var result = createNode(258); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); @@ -10193,7 +10515,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(256); + var result = createNode(257); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18); @@ -10211,7 +10533,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(253); + var result = createNode(254); nextToken(); return finishNode(result); } @@ -10224,29 +10546,35 @@ var ts; token === 27 || token === 56 || token === 47) { - var result = createNode(254, pos); + var result = createNode(255, pos); return finishNode(result); } else { - var result = createNode(258, pos); + var result = createNode(259, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, true, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); + initializeState("file.js", content, 2, undefined, 1); + sourceFile = { languageVariant: 0, text: content }; + var jsDocComment = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; } JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; function parseJSDocComment(parent, start, length) { + var saveToken = token; + var saveParseDiagnosticsLength = parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; var comment = parseJSDocCommentWorker(start, length); if (comment) { - fixupParentReferences(comment); comment.parent = parent; } + token = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; @@ -10259,60 +10587,64 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; - var pos; - if (length >= "/** */".length) { - if (content.charCodeAt(start) === 47 && - content.charCodeAt(start + 1) === 42 && - content.charCodeAt(start + 2) === 42 && - content.charCodeAt(start + 3) !== 42) { + var result; + if (content.charCodeAt(start) === 47 && + content.charCodeAt(start + 1) === 42 && + content.charCodeAt(start + 2) === 42 && + content.charCodeAt(start + 3) !== 42) { + scanner.scanRange(start + 3, length - 5, function () { var canParseTag = true; var seenAsterisk = true; - for (pos = start + "/**".length; pos < end;) { - var ch = content.charCodeAt(pos); - pos++; - if (ch === 64 && canParseTag) { - parseTag(); - canParseTag = false; - continue; - } - if (ts.isLineBreak(ch)) { - canParseTag = true; - seenAsterisk = false; - continue; - } - if (ts.isWhiteSpace(ch)) { - continue; - } - if (ch === 42) { - if (seenAsterisk) { + nextJSDocToken(); + while (token !== 1) { + switch (token) { + case 55: + if (canParseTag) { + parseTag(); + } + seenAsterisk = false; + break; + case 4: + canParseTag = true; + seenAsterisk = false; + break; + case 37: + if (seenAsterisk) { + canParseTag = false; + } + seenAsterisk = true; + break; + case 69: canParseTag = false; - } - seenAsterisk = true; - continue; + break; + case 1: + break; } - canParseTag = false; + nextJSDocToken(); } - } + result = createJSDocComment(); + }); } - return createJSDocComment(); + return result; function createJSDocComment() { if (!tags) { return undefined; } - var result = createNode(268, start); + var result = createNode(269, start); result.tags = tags; return finishNode(result, end); } function skipWhitespace() { - while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { - pos++; + while (token === 5 || token === 4) { + nextJSDocToken(); } } function parseTag() { - ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(55, pos - 1); - atToken.end = pos; - var tagName = scanIdentifier(); + ts.Debug.assert(token === 55); + var atToken = createNode(55, scanner.getTokenPos()); + atToken.end = scanner.getTextPos(); + nextJSDocToken(); + var tagName = parseJSDocIdentifier(); if (!tagName) { return; } @@ -10336,10 +10668,10 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(269, atToken.pos); + var result = createNode(270, atToken.pos); result.atToken = atToken; result.tagName = tagName; - return finishNode(result, pos); + return finishNode(result); } function addTag(tag) { if (tag) { @@ -10352,12 +10684,10 @@ var ts; } } function tryParseTypeExpression() { - skipWhitespace(); - if (content.charCodeAt(pos) !== 123) { + if (token !== 15) { return undefined; } - var typeExpression = parseJSDocTypeExpression(pos, end - pos); - pos = typeExpression.end; + var typeExpression = parseJSDocTypeExpression(); return typeExpression; } function handleParamTag(atToken, tagName) { @@ -10365,17 +10695,20 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (content.charCodeAt(pos) === 91) { - pos++; - skipWhitespace(); - name = scanIdentifier(); + if (parseOptionalToken(19)) { + name = parseJSDocIdentifier(); isBracketed = true; + if (parseOptionalToken(56)) { + parseExpression(); + } + parseExpected(20); } - else { - name = scanIdentifier(); + else if (token === 69) { + name = parseJSDocIdentifier(); } if (!name) { - parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); + parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + return undefined; } var preName, postName; if (typeExpression) { @@ -10387,84 +10720,81 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(270, atToken.pos); + var result = createNode(271, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; result.typeExpression = typeExpression; result.postParameterName = postName; result.isBracketed = isBracketed; - return finishNode(result, pos); + return finishNode(result); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 271; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(271, 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 === 272; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var result = createNode(272, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); + return finishNode(result); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 273; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var typeParameters = []; - typeParameters.pos = pos; - while (true) { - skipWhitespace(); - var startPos = pos; - var name_8 = scanIdentifier(); - if (!name_8) { - parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); - return undefined; - } - var typeParameter = createNode(138, name_8.pos); - typeParameter.name = name_8; - finishNode(typeParameter, pos); - typeParameters.push(typeParameter); - skipWhitespace(); - if (content.charCodeAt(pos) !== 44) { - break; - } - pos++; - } - typeParameters.end = pos; var result = createNode(273, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; - return finishNode(result, pos); + result.typeExpression = tryParseTypeExpression(); + return finishNode(result); } - function scanIdentifier() { - var startPos = pos; - for (; pos < end; pos++) { - var ch = content.charCodeAt(pos); - if (pos === startPos && ts.isIdentifierStart(ch, 2)) { - continue; - } - else if (pos > startPos && ts.isIdentifierPart(ch, 2)) { - continue; - } - break; + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 274; })) { + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - if (startPos === pos) { + var typeParameters = []; + typeParameters.pos = scanner.getStartPos(); + while (true) { + var name_8 = parseJSDocIdentifier(); + if (!name_8) { + parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + return undefined; + } + var typeParameter = createNode(139, name_8.pos); + typeParameter.name = name_8; + finishNode(typeParameter); + typeParameters.push(typeParameter); + if (token === 24) { + nextJSDocToken(); + } + else { + break; + } + } + var result = createNode(274, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeParameters = typeParameters; + finishNode(result); + typeParameters.end = result.end; + return result; + } + function nextJSDocToken() { + return token = scanner.scanJSDocToken(); + } + function parseJSDocIdentifier() { + if (token !== 69) { + parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(69, startPos); - result.text = content.substring(startPos, pos); - return finishNode(result, pos); + var pos = scanner.getTokenPos(); + var end = scanner.getTextPos(); + var result = createNode(69, pos); + result.text = content.substring(pos, end); + finishNode(result, end); + nextJSDocToken(); + return result; } } JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; @@ -10479,7 +10809,7 @@ var ts; return sourceFile; } if (sourceFile.statements.length === 0) { - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind); } var incrementalSourceFile = sourceFile; ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed); @@ -10493,7 +10823,7 @@ var ts; ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange))); var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length; updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks); - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -10562,12 +10892,12 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos = node.pos; + var pos_2 = node.pos; forEachChild(node, function (child) { - ts.Debug.assert(child.pos >= pos); - pos = child.end; + ts.Debug.assert(child.pos >= pos_2); + pos_2 = child.end; }); - ts.Debug.assert(pos <= node.end); + ts.Debug.assert(pos_2 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -10763,32 +11093,32 @@ var ts; : 4; } function getModuleInstanceState(node) { - if (node.kind === 218 || node.kind === 219) { + if (node.kind === 219 || node.kind === 220) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 225 || node.kind === 224) && !(node.flags & 2)) { + else if ((node.kind === 226 || node.kind === 225) && !(node.flags & 1)) { return 0; } - else if (node.kind === 222) { - var state = 0; + else if (node.kind === 223) { + var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { case 0: return false; case 2: - state = 2; + state_1 = 2; return false; case 1: - state = 1; + state_1 = 1; return true; } }); - return state; + return state_1; } - else if (node.kind === 221) { + else if (node.kind === 222) { return getModuleInstanceState(node.body); } else { @@ -10872,7 +11202,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 221)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 222)) { symbol.valueDeclaration = node; } } @@ -10882,7 +11212,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 137) { + if (node.name.kind === 138) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -10893,21 +11223,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 145: + case 146: return "__constructor"; - case 153: - case 148: - return "__call"; case 154: case 149: - return "__new"; + return "__call"; + case 155: case 150: + return "__new"; + case 151: return "__index"; - case 231: + case 232: return "__export"; - case 230: + case 231: return node.isExportEquals ? "export=" : "default"; - case 184: + case 185: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -10919,9 +11249,16 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 216: case 217: + case 218: return node.flags & 512 ? "default" : undefined; + case 265: + return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; + case 140: + ts.Debug.assert(node.parent.kind === 265); + var functionType = node.parent; + var index = ts.indexOf(functionType.parameters, node); + return "p" + index; } } function getDisplayName(node) { @@ -10943,18 +11280,18 @@ var ts; if (node.name) { node.name.parent = node; } - var message = symbol.flags & 2 + var message_1 = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { if (declaration.flags & 512) { - message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message_1, getDisplayName(declaration))); }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message_1, getDisplayName(node))); symbol = createSymbol(0, name); } } @@ -10966,9 +11303,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 2; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 233 || (node.kind === 224 && hasExportModifier)) { + if (node.kind === 234 || (node.kind === 225 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -10976,7 +11313,7 @@ var ts; } } else { - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 131072)) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 8192)) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -11014,12 +11351,12 @@ var ts; var savedHasExplicitReturn; var kind = node.kind; var flags = node.flags; - flags &= ~1572864; - flags &= ~62914560; - if (kind === 218) { + flags &= ~98304; + flags &= ~3932160; + if (kind === 219) { seenThisKeyword = false; } - var saveState = kind === 251 || kind === 222 || ts.isFunctionLikeKind(kind); + var saveState = kind === 252 || kind === 223 || ts.isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -11030,28 +11367,31 @@ var ts; hasExplicitReturn = false; labelStack = labelIndexMap = implicitLabels = undefined; } + if (ts.isInJavaScriptFile(node) && node.jsDocComment) { + bind(node.jsDocComment); + } bindReachableStatement(node); if (currentReachabilityState === 2 && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { - flags |= 524288; + flags |= 32768; if (hasExplicitReturn) { - flags |= 1048576; + flags |= 65536; } } - if (kind === 218) { - flags = seenThisKeyword ? flags | 262144 : flags & ~262144; + if (kind === 219) { + flags = seenThisKeyword ? flags | 16384 : flags & ~16384; } - if (kind === 251) { + if (kind === 252) { if (hasClassExtends) { - flags |= 4194304; + flags |= 262144; } if (hasDecorators) { - flags |= 8388608; + flags |= 524288; } if (hasParameterDecorators) { - flags |= 16777216; + flags |= 1048576; } if (hasAsyncFunctions) { - flags |= 33554432; + flags |= 2097152; } } node.flags = flags; @@ -11072,40 +11412,40 @@ var ts; return; } switch (node.kind) { - case 201: + case 202: bindWhileStatement(node); break; - case 200: + case 201: bindDoStatement(node); break; - case 202: + case 203: bindForStatement(node); break; - case 203: case 204: + case 205: bindForInOrForOfStatement(node); break; - case 199: + case 200: bindIfStatement(node); break; - case 207: - case 211: + case 208: + case 212: bindReturnOrThrow(node); break; + case 207: case 206: - case 205: bindBreakOrContinueStatement(node); break; - case 212: + case 213: bindTryStatement(node); break; - case 209: + case 210: bindSwitchStatement(node); break; - case 223: + case 224: bindCaseBlock(node); break; - case 210: + case 211: bindLabeledStatement(node); break; default: @@ -11167,14 +11507,14 @@ var ts; } function bindReturnOrThrow(n) { bind(n.expression); - if (n.kind === 207) { + if (n.kind === 208) { hasExplicitReturn = true; } currentReachabilityState = 4; } function bindBreakOrContinueStatement(n) { bind(n.label); - var isValidJump = jumpToLabel(n.label, n.kind === 206 ? currentReachabilityState : 4); + var isValidJump = jumpToLabel(n.label, n.kind === 207 ? currentReachabilityState : 4); if (isValidJump) { currentReachabilityState = 4; } @@ -11195,7 +11535,7 @@ var ts; var postSwitchLabel = pushImplicitLabel(); bind(n.expression); bind(n.caseBlock); - var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 245; }); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 246; }); var postSwitchState = hasDefault && currentReachabilityState !== 2 ? 4 : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); } @@ -11220,37 +11560,38 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 189: - case 217: + case 190: case 218: - case 220: - case 156: - case 168: + case 219: + case 221: + case 169: + case 157: + case 261: return 1; - case 148: case 149: case 150: - case 144: - case 143: - case 216: + case 151: case 145: + case 144: + case 217: case 146: case 147: - case 153: + case 148: case 154: - case 176: + case 155: case 177: - case 221: - case 251: - case 219: + case 178: + case 222: + case 252: + case 220: return 5; - case 247: - case 202: + case 248: case 203: case 204: - case 223: + case 205: + case 224: return 2; - case 195: + case 196: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -11266,38 +11607,40 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 221: + case 222: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 251: + case 252: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 189: - case 217: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 220: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 156: - case 168: + case 190: case 218: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 221: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 157: + case 169: + case 219: + case 261: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 153: case 154: - case 148: + case 155: case 149: case 150: - case 144: - case 143: + case 151: case 145: + case 144: case 146: case 147: - case 216: - case 176: + case 148: + case 217: case 177: - case 219: + case 178: + case 265: + case 220: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 64 + return node.flags & 32 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -11307,11 +11650,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 251 ? node : node.body; - if (body.kind === 251 || body.kind === 222) { + var body = node.kind === 252 ? node : node.body; + if (body.kind === 252 || body.kind === 223) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 231 || stat.kind === 230) { + if (stat.kind === 232 || stat.kind === 231) { return true; } } @@ -11320,16 +11663,16 @@ var ts; } function setExportContextFlag(node) { if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 131072; + node.flags |= 8192; } else { - node.flags &= ~131072; + node.flags &= ~8192; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (node.flags & 2) { + if (node.flags & 1) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } declareSymbolAndAddToSymbolTable(node, 512, 106639); @@ -11373,7 +11716,7 @@ var ts; continue; } var identifier = prop.name; - var currentKind = prop.kind === 248 || prop.kind === 249 || prop.kind === 144 + var currentKind = prop.kind === 249 || prop.kind === 250 || prop.kind === 145 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -11395,10 +11738,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 221: + case 222: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 251: + case 252: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -11477,7 +11820,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 32768) { + if (inStrictMode && node.isOctalLiteral) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -11520,17 +11863,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 251: - case 222: + case 252: + case 223: updateStrictModeStatementList(node.statements); return; - case 195: + case 196: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 217: - case 189: + case 218: + case 190: inStrictMode = true; return; } @@ -11555,7 +11898,7 @@ var ts; switch (node.kind) { case 69: return checkStrictModeIdentifier(node); - case 184: + case 185: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -11578,91 +11921,94 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 247: + case 248: return checkStrictModeCatchClause(node); - case 178: + case 179: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 183: + case 184: return checkStrictModePostfixUnaryExpression(node); - case 182: + case 183: return checkStrictModePrefixUnaryExpression(node); - case 208: + case 209: return checkStrictModeWithStatement(node); - case 162: + case 163: seenThisKeyword = true; return; - case 151: + case 152: return checkTypePredicate(node); - case 138: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); case 139: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 140: return bindParameter(node); - case 214: - case 166: + case 215: + case 167: return bindVariableDeclarationOrBindingElement(node); + case 143: case 142: - case 141: + case 262: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 248: case 249: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 250: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 251: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 148: case 149: case 150: + case 151: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 144: - case 143: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 216: - return bindFunctionDeclaration(node); case 145: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 144: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); + case 217: + return bindFunctionDeclaration(node); case 146: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 147: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 148: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 153: case 154: + case 155: + case 265: return bindFunctionOrConstructorType(node); - case 156: + case 157: + case 261: return bindAnonymousDeclaration(node, 2048, "__type"); - case 168: + case 169: return bindObjectLiteralExpression(node); - case 176: case 177: + case 178: return bindFunctionExpression(node); - case 171: + case 172: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 189: - case 217: - return bindClassLikeDeclaration(node); + case 190: case 218: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 219: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 220: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 221: + return bindEnumDeclaration(node); + case 222: return bindModuleDeclaration(node); - case 224: - case 227: - case 229: - case 233: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 226: - return bindImportClause(node); - case 231: - return bindExportDeclaration(node); + case 225: + case 228: case 230: + case 234: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 227: + return bindImportClause(node); + case 232: + return bindExportDeclaration(node); + case 231: return bindExportAssignment(node); - case 251: + case 252: return bindSourceFileIfExternalModule(); } } @@ -11671,7 +12017,7 @@ var ts; if (parameterName && parameterName.kind === 69) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 162) { + if (parameterName && parameterName.kind === 163) { seenThisKeyword = true; } bind(type); @@ -11686,11 +12032,11 @@ var ts; bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } function bindExportAssignment(node) { - var boundExpression = node.kind === 230 ? node.expression : node.right; + var boundExpression = node.kind === 231 ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (boundExpression.kind === 69) { + else if (boundExpression.kind === 69 && node.kind === 231) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -11725,24 +12071,29 @@ var ts; bindExportAssignment(node); } function bindThisPropertyAssignment(node) { - if (container.kind === 176 || container.kind === 216) { + if (container.kind === 177 || container.kind === 217) { container.symbol.members = container.symbol.members || {}; - declareSymbol(container.symbol.members, container.symbol, node, 4, 107455); + declareSymbol(container.symbol.members, container.symbol, node, 4, 107455 & ~4); } } function bindPrototypePropertyAssignment(node) { - var classId = node.left.expression.expression; - var funcSymbol = container.locals[classId.text]; + var leftSideOfAssignment = node.left; + var classPrototype = leftSideOfAssignment.expression; + var constructorFunction = classPrototype.expression; + leftSideOfAssignment.parent = node; + constructorFunction.parent = classPrototype; + classPrototype.parent = leftSideOfAssignment; + var funcSymbol = container.locals[constructorFunction.text]; if (!funcSymbol || !(funcSymbol.flags & 16)) { return; } if (!funcSymbol.members) { funcSymbol.members = {}; } - declareSymbol(funcSymbol.members, funcSymbol, node.left, 4, 107455); + declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 107455); } function bindCallExpression(node) { - if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) { setCommonJsModuleIndicator(node); } } @@ -11755,7 +12106,7 @@ var ts; hasDecorators = true; } } - if (node.kind === 217) { + if (node.kind === 218) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -11905,16 +12256,16 @@ var ts; function checkUnreachable(node) { switch (currentReachabilityState) { case 4: - var reportError = (ts.isStatement(node) && node.kind !== 197) || - node.kind === 217 || - (node.kind === 221 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 220 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatement(node) && node.kind !== 198) || + node.kind === 218 || + (node.kind === 222 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 221 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentReachabilityState = 8; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 196 || - ts.getCombinedNodeFlags(node.declarationList) & 24576 || + (node.kind !== 197 || + ts.getCombinedNodeFlags(node.declarationList) & 3072 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); @@ -11974,8 +12325,8 @@ var ts; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 ? 5 : 0; - var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === 4; + var modulekind = ts.getEmitModuleKind(compilerOptions); + var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 | 67108864, "undefined"); undefinedSymbol.declarations = []; @@ -12041,14 +12392,16 @@ var ts; 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, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); + var enumNumberIndexInfo = createIndexInfo(stringType, true); var globals = {}; var globalESSymbolConstructorSymbol; var getGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; + var globalReadonlyArrayType; var globalStringType; var globalNumberType; var globalBooleanType; @@ -12059,6 +12412,7 @@ var ts; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; + var anyReadonlyArrayType; var getGlobalClassDecoratorType; var getGlobalParameterDecoratorType; var getGlobalPropertyDecoratorType; @@ -12208,7 +12562,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 221 && source.valueDeclaration.kind !== 221))) { + (target.valueDeclaration.kind === 222 && source.valueDeclaration.kind !== 222))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -12227,13 +12581,13 @@ var ts; recordMergedSymbol(target, source); } else { - var message = target.flags & 2 || source.flags & 2 + var message_2 = target.flags & 2 || source.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(source.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); + error(node.name ? node.name : node, message_2, symbolToString(source)); }); ts.forEach(target.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); + error(node.name ? node.name : node, message_2, symbolToString(source)); }); } } @@ -12276,8 +12630,14 @@ var ts; if (!mainModule) { return; } - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); - mergeSymbol(mainModule, moduleAugmentation.symbol); + mainModule = resolveExternalModuleSymbol(mainModule); + if (mainModule.flags & 1536) { + mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); + mergeSymbol(mainModule, moduleAugmentation.symbol); + } + else { + error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text); + } } } function addToSymbolTable(target, source, message) { @@ -12306,7 +12666,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function isGlobalSourceFile(node) { - return node.kind === 251 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 252 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -12324,9 +12684,9 @@ var ts; } } function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { - var constructoDeclaration = parameter.parent; + var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructoDeclaration.locals, parameterName, 107455); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 107455); var propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, 107455); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; @@ -12344,18 +12704,18 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 214 || + return declaration.kind !== 215 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 196 || - declaration.parent.parent.kind === 202) { + if (declaration.parent.parent.kind === 197 || + declaration.parent.parent.kind === 203) { return isSameScopeDescendentOf(usage, declaration, container); } - else if (declaration.parent.parent.kind === 204 || - declaration.parent.parent.kind === 203) { + else if (declaration.parent.parent.kind === 205 || + declaration.parent.parent.kind === 204) { var expression = declaration.parent.parent.expression; return isSameScopeDescendentOf(usage, expression, container); } @@ -12371,8 +12731,8 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 142 && - (current.parent.flags & 64) === 0 && + current.parent.kind === 143 && + (current.parent.flags & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -12393,18 +12753,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793056) { + if (meaning & result.flags & 793056 && lastLocation.kind !== 269) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 139 || - lastLocation.kind === 138 + lastLocation.kind === 140 || + lastLocation.kind === 139 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 139 || + lastLocation.kind === 140 || (lastLocation === location.type && - result.valueDeclaration.kind === 139); + result.valueDeclaration.kind === 140); } } if (useResult) { @@ -12416,12 +12776,12 @@ var ts; } } switch (location.kind) { - case 251: + case 252: if (!ts.isExternalOrCommonJsModule(location)) break; - case 221: + case 222: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 251 || ts.isAmbientModule(location)) { + if (location.kind === 252 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -12431,7 +12791,7 @@ var ts; } if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 233)) { + ts.getDeclarationOfKind(moduleExports[name], 234)) { break; } } @@ -12439,14 +12799,14 @@ var ts; break loop; } break; - case 220: + case 221: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 143: case 142: - case 141: - if (ts.isClassLike(location.parent) && !(location.flags & 64)) { + if (ts.isClassLike(location.parent) && !(location.flags & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -12455,17 +12815,17 @@ var ts; } } break; - case 217: - case 189: case 218: + case 190: + case 219: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { - if (lastLocation && lastLocation.flags & 64) { + if (lastLocation && lastLocation.flags & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } break loop; } - if (location.kind === 189 && meaning & 32) { + if (location.kind === 190 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -12473,28 +12833,28 @@ var ts; } } break; - case 137: + case 138: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 218) { + if (ts.isClassLike(grandparent) || grandparent.kind === 219) { 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 144: - case 143: case 145: + case 144: case 146: case 147: - case 216: - case 177: + case 148: + case 217: + case 178: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 176: + case 177: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -12507,8 +12867,8 @@ var ts; } } break; - case 140: - if (location.parent && location.parent.kind === 139) { + case 141: + if (location.parent && location.parent.kind === 140) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -12562,7 +12922,7 @@ var ts; error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg), symbolToString(classSymbol)); return true; } - if (location === container && !(location.flags & 64)) { + if (location === container && !(location.flags & 32)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); @@ -12578,7 +12938,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 214), errorLocation)) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 215), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -12595,10 +12955,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 224) { + if (node.kind === 225) { return node; } - while (node && node.kind !== 225) { + while (node && node.kind !== 226) { node = node.parent; } return node; @@ -12608,7 +12968,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 235) { + if (node.moduleReference.kind === 236) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -12621,7 +12981,7 @@ var ts; error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { - return resolveSymbol(moduleSymbol.exports["export="]) || resolveSymbol(moduleSymbol); + return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } return exportDefaultSymbol; } @@ -12692,17 +13052,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 224: + case 225: return getTargetOfImportEqualsDeclaration(node); - case 226: - return getTargetOfImportClause(node); case 227: + return getTargetOfImportClause(node); + case 228: return getTargetOfNamespaceImport(node); - case 229: - return getTargetOfImportSpecifier(node); - case 233: - return getTargetOfExportSpecifier(node); case 230: + return getTargetOfImportSpecifier(node); + case 234: + return getTargetOfExportSpecifier(node); + case 231: return getTargetOfExportAssignment(node); } } @@ -12744,10 +13104,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 230) { + if (node.kind === 231) { checkExpressionCached(node.expression); } - else if (node.kind === 233) { + else if (node.kind === 234) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -12757,17 +13117,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 224); + importDeclaration = ts.getAncestor(entityName, 225); ts.Debug.assert(importDeclaration !== undefined); } if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 136) { + if (entityName.kind === 69 || entityName.parent.kind === 137) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 224); + ts.Debug.assert(entityName.parent.kind === 225); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -12786,9 +13146,9 @@ var ts; return undefined; } } - else if (name.kind === 136 || name.kind === 169) { - var left = name.kind === 136 ? name.left : name.expression; - var right = name.kind === 136 ? name.right : name.name; + else if (name.kind === 137 || name.kind === 170) { + var left = name.kind === 137 ? name.left : name.expression; + var right = name.kind === 137 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -12843,7 +13203,7 @@ var ts; return undefined; } function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; } function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { var symbol = resolveExternalModuleSymbol(moduleSymbol); @@ -12853,8 +13213,8 @@ var ts; } return symbol; } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="]; + function hasExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="] !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -12951,7 +13311,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 145 && ts.nodeIsPresent(member.body)) { + if (member.kind === 146 && ts.nodeIsPresent(member.body)) { return member; } } @@ -12994,19 +13354,19 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; + if (stringIndexInfo) + type.stringIndexInfo = stringIndexInfo; + if (numberIndexInfo) + type.numberIndexInfo = numberIndexInfo; return type; } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -13017,17 +13377,17 @@ var ts; } } switch (location_1.kind) { - case 251: + case 252: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 221: + case 222: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 217: case 218: + case 219: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13060,7 +13420,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 234)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -13089,7 +13449,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 234)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -13144,7 +13504,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 251 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 252 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -13156,7 +13516,7 @@ var ts; if (!isDeclarationVisible(declaration)) { var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 2) && + !(anyImportSyntax.flags & 1) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -13176,11 +13536,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 155) { + if (entityName.parent.kind === 156) { meaning = 107455 | 1048576; } - else if (entityName.kind === 136 || entityName.kind === 169 || - entityName.parent.kind === 224) { + else if (entityName.kind === 137 || entityName.kind === 170 || + entityName.parent.kind === 225) { meaning = 1536; } else { @@ -13228,13 +13588,29 @@ var ts; } return result; } + function typePredicateToString(typePredicate, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function visibilityToString(flags) { + if (flags === 8) { + return "private"; + } + if (flags === 16) { + return "protected"; + } + return "public"; + } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 161) { + while (node.kind === 162) { node = node.parent; } - if (node.kind === 219) { + if (node.kind === 220) { return getSymbolOfNode(node); } } @@ -13242,7 +13618,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 222 && + node.parent.kind === 223 && ts.isExternalModuleAugmentation(node.parent.parent); } function getSymbolDisplayBuilder() { @@ -13253,10 +13629,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 189: + case 190: return "(Anonymous class)"; - case 176: case 177: + case 178: return "(Anonymous function)"; } } @@ -13321,15 +13697,9 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { if (type.flags & 16777343) { - if (type.flags & 134217728) { - buildTypePredicateDisplay(writer, type.predicate); - buildTypeDisplay(type.predicate.type, writer, enclosingDeclaration, flags, symbolStack); - } - else { - writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) - ? "any" - : type.intrinsicName); - } + writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) + ? "any" + : type.intrinsicName); } else if (type.flags & 33554432) { if (inObjectTypeLiteral) { @@ -13406,12 +13776,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_4 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_4); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_4, typeArguments, start, i, flags); writePunctuation(writer, 21); } } @@ -13466,11 +13836,11 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 32; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 251 || declaration.parent.kind === 222; + return declaration.parent.kind === 252 || declaration.parent.kind === 223; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -13483,17 +13853,38 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } - function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); - if (!declaration) { - return fallbackName; + function writeIndexSignature(info, keyword) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 127); + writeSpace(writer); + } + writePunctuation(writer, 19); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 54); + writeSpace(writer); + writeKeyword(writer, keyword); + writePunctuation(writer, 20); + writePunctuation(writer, 54); + writeSpace(writer); + writeType(info.type, 0); + writePunctuation(writer, 23); + writer.writeLine(); + } + } + function writePropertyWithModifiers(prop) { + if (isReadonlySymbol(prop)) { + writeKeyword(writer, 127); + writeSpace(writer); + } + buildSymbolDisplay(prop, writer); + if (prop.flags & 536870912) { + writePunctuation(writer, 53); } - ts.Debug.assert(declaration.parameters.length !== 0); - return ts.declarationNameToString(declaration.parameters[0].name); } function writeLiteralType(type, flags) { var resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 15); writePunctuation(writer, 16); @@ -13539,32 +13930,8 @@ var ts; writePunctuation(writer, 23); writer.writeLine(); } - if (resolved.stringIndexType) { - writePunctuation(writer, 19); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 54); - writeSpace(writer); - writeKeyword(writer, 130); - writePunctuation(writer, 20); - writePunctuation(writer, 54); - writeSpace(writer); - writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } - if (resolved.numberIndexType) { - writePunctuation(writer, 19); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 54); - writeSpace(writer); - writeKeyword(writer, 128); - writePunctuation(writer, 20); - writePunctuation(writer, 54); - writeSpace(writer); - writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 23); - writer.writeLine(); - } + writeIndexSignature(resolved.stringIndexInfo, 131); + writeIndexSignature(resolved.numberIndexInfo, 129); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -13572,20 +13939,14 @@ var ts; var signatures = getSignaturesOfType(t, 0); for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { var signature = signatures_1[_f]; - buildSymbolDisplay(p, writer); - if (p.flags & 536870912) { - writePunctuation(writer, 53); - } + writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); writePunctuation(writer, 23); writer.writeLine(); } } else { - buildSymbolDisplay(p, writer); - if (p.flags & 536870912) { - writePunctuation(writer, 53); - } + writePropertyWithModifiers(p); writePunctuation(writer, 54); writeSpace(writer); writeType(t, 0); @@ -13598,10 +13959,10 @@ var ts; inObjectTypeLiteral = saveInObjectTypeLiteral; } } - function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { + function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaration, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -13664,7 +14025,7 @@ var ts; } writePunctuation(writer, 18); } - function buildTypePredicateDisplay(writer, predicate) { + function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } @@ -13674,6 +14035,7 @@ var ts; writeSpace(writer); writeKeyword(writer, 124); writeSpace(writer); + buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { @@ -13684,8 +14046,13 @@ var ts; writePunctuation(writer, 54); } writeSpace(writer); - var returnType = getReturnTypeOfSignature(signature); - buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + if (signature.typePredicate) { + buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); + } + else { + var returnType = getReturnTypeOfSignature(signature); + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { @@ -13705,6 +14072,7 @@ var ts; buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, + buildTypePredicateDisplay: buildTypePredicateDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, @@ -13724,63 +14092,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 166: + case 167: return isDeclarationVisible(node.parent.parent); - case 214: + case 215: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 221: - case 217: + case 222: case 218: case 219: - case 216: case 220: - case 224: + case 217: + case 221: + case 225: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_4 = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 2) && - !(node.kind !== 224 && parent_4.kind !== 251 && ts.isInAmbientContext(parent_4))) { - return isGlobalSourceFile(parent_4); + var parent_5 = getDeclarationContainer(node); + if (!(ts.getCombinedNodeFlags(node) & 1) && + !(node.kind !== 225 && parent_5.kind !== 252 && ts.isInAmbientContext(parent_5))) { + return isGlobalSourceFile(parent_5); } - return isDeclarationVisible(parent_4); - case 142: - case 141: - case 146: - case 147: - case 144: + return isDeclarationVisible(parent_5); case 143: - if (node.flags & (16 | 32)) { + case 142: + case 147: + case 148: + case 145: + case 144: + if (node.flags & (8 | 16)) { return false; } - case 145: - case 149: - case 148: + case 146: case 150: - case 139: - case 222: - case 153: + case 149: + case 151: + case 140: + case 223: case 154: - case 156: - case 152: + case 155: case 157: + case 153: case 158: case 159: case 160: case 161: + case 162: return isDeclarationVisible(node.parent); - case 226: case 227: - case 229: - return false; - case 138: - case 251: - return true; + case 228: case 230: return false; + case 139: + case 252: + return true; + case 231: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -13788,10 +14156,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 230) { + if (node.parent && node.parent.kind === 231) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 233) { + else if (node.parent.kind === 234) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -13868,10 +14236,23 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 214 ? node.parent.parent.parent : node.parent; + while (node) { + switch (node.kind) { + case 215: + case 216: + case 230: + case 229: + case 228: + case 227: + node = node.parent; + break; + default: + return node.parent; + } + } } function getTypeOfPrototypeProperty(prototype) { - var classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); + var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } function getTypeOfPropertyOfType(type, name) { @@ -13892,7 +14273,7 @@ var ts; case 9: case 8: return name.text; - case 137: + case 138: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -13900,7 +14281,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 137 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 138 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -13915,7 +14296,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 164) { + if (pattern.kind === 165) { var name_10 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_10)) { return anyType; @@ -13952,11 +14333,44 @@ var ts; } return type; } + function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + var jsDocType = getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (jsDocType) { + return getTypeFromTypeNode(jsDocType); + } + } + function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + var typeTag = ts.getJSDocTypeTag(declaration); + if (typeTag && typeTag.typeExpression) { + return typeTag.typeExpression.type; + } + if (declaration.kind === 215 && + declaration.parent.kind === 216 && + declaration.parent.parent.kind === 197) { + var annotation = ts.getJSDocTypeTag(declaration.parent.parent); + if (annotation && annotation.typeExpression) { + return annotation.typeExpression.type; + } + } + else if (declaration.kind === 140) { + var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type; + } + } + return undefined; + } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 203) { - return stringType; + if (declaration.flags & 134217728) { + var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (type && type !== unknownType) { + return type; + } } if (declaration.parent.parent.kind === 204) { + return stringType; + } + if (declaration.parent.parent.kind === 205) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -13965,10 +14379,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 139) { + if (declaration.kind === 140) { var func = declaration.parent; - if (func.kind === 147 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 146); + if (func.kind === 148 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 147); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -13981,7 +14395,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 249) { + if (declaration.kind === 250) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -14028,7 +14442,7 @@ var ts; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - var elementTypes = ts.map(elements, function (e) { return e.kind === 190 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 191 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -14037,7 +14451,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 164 + return pattern.kind === 165 ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -14047,10 +14461,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 248) { - return type; - } - if (type.flags & 134217728 && (declaration.kind === 142 || declaration.kind === 141)) { + if (declaration.kind === 249) { return type; } return getWidenedType(type); @@ -14058,7 +14469,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 139 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 140 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -14071,17 +14482,17 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 247) { + if (declaration.parent.kind === 248) { return links.type = anyType; } - if (declaration.kind === 230) { + if (declaration.kind === 231) { return links.type = checkExpression(declaration.expression); } - if (declaration.kind === 184) { - return links.type = checkExpression(declaration.right); + if (declaration.kind === 185) { + return links.type = getUnionType(ts.map(symbol.declarations, function (decl) { return checkExpressionCached(decl.right); })); } - if (declaration.kind === 169) { - if (declaration.parent.kind === 184) { + if (declaration.kind === 170) { + if (declaration.parent.kind === 185) { return links.type = checkExpressionCached(declaration.parent.right); } } @@ -14107,7 +14518,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 146) { + if (accessor.kind === 147) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -14123,9 +14534,9 @@ var ts; if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 146); - var setter = ts.getDeclarationOfKind(symbol, 147); - var type; + var getter = ts.getDeclarationOfKind(symbol, 147); + var setter = ts.getDeclarationOfKind(symbol, 148); + var type = void 0; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { type = getterReturnType; @@ -14150,7 +14561,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 146); + var getter_1 = ts.getDeclarationOfKind(symbol, 147); 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)); } } @@ -14239,9 +14650,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 217 || node.kind === 189 || - node.kind === 216 || node.kind === 176 || - node.kind === 144 || node.kind === 177) { + if (node.kind === 218 || node.kind === 190 || + node.kind === 217 || node.kind === 177 || + node.kind === 145 || node.kind === 178) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -14250,15 +14661,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 218); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 219); 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 === 218 || node.kind === 217 || - node.kind === 189 || node.kind === 219) { + if (node.kind === 219 || node.kind === 218 || + node.kind === 190 || node.kind === 220) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -14283,8 +14694,8 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { - var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); } return signatures; } @@ -14381,7 +14792,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 218 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 219 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -14410,8 +14821,8 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 218) { - if (declaration.flags & 262144) { + if (declaration.kind === 219) { + if (declaration.flags & 16384) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -14459,7 +14870,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 219); + var declaration = ts.getDeclarationOfKind(symbol, 220); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -14490,7 +14901,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 138).constraint) { + if (!ts.getDeclarationOfKind(symbol, 139).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -14537,16 +14948,16 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: case 103: - case 163: + case 164: return true; - case 157: + case 158: return isIndependentType(node.elementType); - case 152: + case 153: return isIndependentTypeReference(node); } return false; @@ -14555,7 +14966,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 145 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 146 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -14571,12 +14982,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 142: - case 141: - return isIndependentVariableLikeDeclaration(declaration); - case 144: case 143: + case 142: + return isIndependentVariableLikeDeclaration(declaration); case 145: + case 144: + case 146: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -14613,8 +15024,8 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0); + type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1); } return type; } @@ -14629,15 +15040,15 @@ var ts; var members = source.symbol.members; var callSignatures = source.declaredCallSignatures; var constructSignatures = source.declaredConstructSignatures; - var stringIndexType = source.declaredStringIndexType; - var numberIndexType = source.declaredNumberIndexType; + var stringIndexInfo = source.declaredStringIndexInfo; + var numberIndexInfo = source.declaredNumberIndexInfo; if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); - stringIndexType = instantiateType(source.declaredStringIndexType, mapper); - numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); + numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); } var baseTypes = getBaseTypes(source); if (baseTypes.length) { @@ -14651,11 +15062,11 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1); + stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); + numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); @@ -14667,25 +15078,26 @@ var ts; type.typeArguments : ts.concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, false, false)]; + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, undefined, 0, false, false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); @@ -14717,7 +15129,7 @@ var ts; var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { @@ -14773,41 +15185,46 @@ var ts; } return result || emptyArray; } - function getUnionIndexType(types, kind) { + function getUnionIndexInfo(types, kind) { var indexTypes = []; + var isAnyReadonly = false; for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { var type = types_1[_i]; - var indexType = getIndexTypeOfType(type, kind); - if (!indexType) { + var indexInfo = getIndexInfoOfType(type, kind); + if (!indexInfo) { return undefined; } - indexTypes.push(indexType); + indexTypes.push(indexInfo.type); + isAnyReadonly = isAnyReadonly || indexInfo.isReadonly; } - return getUnionType(indexTypes); + return createIndexInfo(getUnionType(indexTypes), isAnyReadonly); } function resolveUnionTypeMembers(type) { var callSignatures = getUnionSignatures(type.types, 0); var constructSignatures = getUnionSignatures(type.types, 1); - var stringIndexType = getUnionIndexType(type.types, 0); - var numberIndexType = getUnionIndexType(type.types, 1); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = getUnionIndexInfo(type.types, 0); + var numberIndexInfo = getUnionIndexInfo(type.types, 1); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } + function intersectIndexInfos(info1, info2) { + return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexType = undefined; - var numberIndexType = undefined; + var stringIndexInfo = undefined; + var numberIndexInfo = undefined; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); - stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0)); - numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1)); + stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); + numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; @@ -14815,17 +15232,17 @@ var ts; var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); var callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); var constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); - var stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0), type.mapper); - var numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1), type.mapper); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper); + var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048) { var members = symbol.members; var callSignatures = getSignaturesOfSymbol(members["__call"]); var constructSignatures = getSignaturesOfSymbol(members["__new"]); - var stringIndexType = getIndexTypeOfSymbol(symbol, 0); - var numberIndexType = getIndexTypeOfSymbol(symbol, 1); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); + var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { var members = emptySymbols; @@ -14845,8 +15262,8 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } - var numberIndexType = (symbol.flags & 384) ? stringType : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexType); + var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; + setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } @@ -14946,7 +15363,7 @@ var ts; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 | 32))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (8 | 16))) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -15028,15 +15445,44 @@ var ts; function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } - function getIndexTypeOfStructuredType(type, kind) { + function getIndexInfoOfStructuredType(type, kind) { if (type.flags & 130048) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; + return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo; } } + function getIndexTypeOfStructuredType(type, kind) { + var info = getIndexInfoOfStructuredType(type, kind); + return info && info.type; + } + function getIndexInfoOfType(type, kind) { + return getIndexInfoOfStructuredType(getApparentType(type), kind); + } function getIndexTypeOfType(type, kind) { return getIndexTypeOfStructuredType(getApparentType(type), kind); } + function getImplicitIndexTypeOfType(type, kind) { + if (isObjectLiteralType(type)) { + var propTypes = []; + for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + if (kind === 0 || isNumericLiteralName(prop.name)) { + propTypes.push(getTypeOfSymbol(prop)); + } + } + return getUnionType(propTypes); + } + return undefined; + } + function getTypeParametersFromJSDocTemplate(declaration) { + if (declaration.flags & 134217728) { + var templateTag = ts.getJSDocTemplateTag(declaration); + if (templateTag) { + return getTypeParametersFromDeclaration(templateTag.typeParameters); + } + } + return undefined; + } function getTypeParametersFromDeclaration(typeParameterDeclarations) { var result = []; ts.forEach(typeParameterDeclarations, function (node) { @@ -15057,6 +15503,20 @@ var ts; return result; } function isOptionalParameter(node) { + if (node.flags & 134217728) { + if (node.type && node.type.kind === 264) { + return true; + } + var paramTag = ts.getCorrespondingJSDocParameterTag(node); + if (paramTag) { + if (paramTag.isBracketed) { + return true; + } + if (paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 264; + } + } + } if (ts.hasQuestionToken(node)) { return true; } @@ -15089,15 +15549,19 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 145 ? + var classType = declaration.kind === 146 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : - declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; + declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : + getTypeParametersFromJSDocTemplate(declaration); var parameters = []; var hasStringLiterals = false; var minArgumentCount = -1; - for (var i = 0, n = declaration.parameters.length; i < n; i++) { + var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var returnType = undefined; + var typePredicate = undefined; + for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { @@ -15105,7 +15569,7 @@ var ts; paramSymbol = resolvedSymbol; } parameters.push(paramSymbol); - if (param.type && param.type.kind === 163) { + if (param.type && param.type.kind === 164) { hasStringLiterals = true; } if (param.initializer || param.questionToken || param.dotDotDotToken) { @@ -15120,23 +15584,35 @@ var ts; if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; } - var returnType; - if (classType) { + if (isJSConstructSignature) { + minArgumentCount--; + returnType = getTypeFromTypeNode(declaration.parameters[0].type); + } + else if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 152) { + typePredicate = createTypePredicateFromTypePredicateNode(declaration.type); + } } else { - if (declaration.kind === 146 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 147); + if (declaration.flags & 134217728) { + var type = getReturnTypeFromJSDocComment(declaration); + if (type && type !== unknownType) { + returnType = type; + } + } + if (declaration.kind === 147 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 148); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -15147,19 +15623,20 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 153: case 154: - case 216: - case 144: - case 143: + case 155: + case 217: case 145: - case 148: + case 144: + case 146: case 149: case 150: - case 146: + case 151: case 147: - case 176: + case 148: case 177: + case 178: + case 265: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -15186,7 +15663,7 @@ var ts; if (!pushTypeResolution(signature, 3)) { return unknownType; } - var type; + var type = void 0; if (signature.target) { type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); } @@ -15239,7 +15716,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 145 || signature.declaration.kind === 149; + var isConstructor = signature.declaration.kind === 146 || signature.declaration.kind === 150; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -15253,7 +15730,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 128 : 130; + var syntaxKind = kind === 1 ? 129 : 131; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -15269,18 +15746,22 @@ var ts; } return undefined; } - function getIndexTypeOfSymbol(symbol, kind) { + function createIndexInfo(type, isReadonly, declaration) { + return { type: type, isReadonly: isReadonly, declaration: declaration }; + } + function getIndexInfoOfSymbol(symbol, kind) { var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType - : undefined; + if (declaration) { + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, (declaration.flags & 64) !== 0, declaration); + } + return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 138).constraint; + return ts.getDeclarationOfKind(type.symbol, 139).constraint; } function hasConstraintReferenceTo(type, target) { var checked; - while (type && type.flags & 512 && !ts.contains(checked, type)) { + while (type && !(type.flags & 33554432) && type.flags & 512 && !ts.contains(checked, type)) { if (type === target) { return true; } @@ -15309,7 +15790,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 138).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 139).parent); } function getTypeListId(types) { if (types) { @@ -15392,17 +15873,62 @@ var ts; } return getDeclaredTypeOfSymbol(symbol); } + function getTypeReferenceName(node) { + switch (node.kind) { + case 153: + return node.typeName; + case 263: + return node.name; + case 192: + if (ts.isSupportedExpressionWithTypeArguments(node)) { + return node.expression; + } + } + return undefined; + } + function resolveTypeReferenceName(node, typeReferenceName) { + if (!typeReferenceName) { + return unknownSymbol; + } + return resolveEntityName(typeReferenceName, 793056) || unknownSymbol; + } + function getTypeReferenceType(node, symbol) { + if (symbol === unknownSymbol) { + return unknownType; + } + if (symbol.flags & (32 | 64)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288) { + return getTypeFromTypeAliasReference(node, symbol); + } + if (symbol.flags & 107455 && node.kind === 263) { + return getTypeOfSymbol(symbol); + } + return getTypeFromNonGenericTypeReference(node, symbol); + } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 152 ? node.typeName : - ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : - undefined; - var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; - var type = symbol === unknownSymbol ? unknownType : - symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + var symbol = void 0; + var type = void 0; + if (node.kind === 263) { + var typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(node, typeReferenceName); + type = getTypeReferenceType(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + else { + var typeNameOrExpression = node.kind === 153 ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; + type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 | 64) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + } links.resolvedSymbol = symbol; links.resolvedType = type; } @@ -15421,9 +15947,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 217: case 218: - case 220: + case 219: + case 221: return declaration; } } @@ -15636,12 +16162,28 @@ var ts; } return links.resolvedType; } + function getTypeFromJSDocVariadicType(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var type = getTypeFromTypeNode(node.type); + links.resolvedType = type ? createArrayType(type) : unknownType; + } + return links.resolvedType; + } + function getTypeFromJSDocTupleType(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var types = ts.map(node.types, getTypeFromTypeNode); + links.resolvedType = createTupleType(types); + } + return links.resolvedType; + } function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 218)) { - if (!(container.flags & 64) && - (container.kind !== 145 || ts.isNodeDescendentOf(node, container.body))) { + if (parent && (ts.isClassLike(parent) || parent.kind === 219)) { + if (!(container.flags & 32) && + (container.kind !== 146 || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -15655,66 +16197,66 @@ var ts; } return links.resolvedType; } - function getPredicateType(node) { - return createPredicateType(getSymbolOfNode(node), createTypePredicateFromTypePredicateNode(node)); - } - function createPredicateType(symbol, predicate) { - var type = createType(8 | 134217728); - type.symbol = symbol; - type.predicate = predicate; - return type; - } - function getTypeFromPredicateTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getPredicateType(node); - } - return links.resolvedType; - } function getTypeFromTypeNode(node) { switch (node.kind) { case 117: + case 254: + case 255: return anyType; - case 130: + case 131: return stringType; - case 128: + case 129: return numberType; case 120: return booleanType; - case 131: + case 132: return esSymbolType; case 103: return voidType; - case 162: - return getTypeFromThisTypeNode(node); case 163: + return getTypeFromThisTypeNode(node); + case 164: return getTypeFromStringLiteralTypeNode(node); - case 152: - return getTypeFromTypeReference(node); - case 151: - return getTypeFromPredicateTypeNode(node); - case 191: - return getTypeFromTypeReference(node); - case 155: - return getTypeFromTypeQueryNode(node); - case 157: - return getTypeFromArrayTypeNode(node); - case 158: - return getTypeFromTupleTypeNode(node); - case 159: - return getTypeFromUnionTypeNode(node); - case 160: - return getTypeFromIntersectionTypeNode(node); - case 161: - return getTypeFromTypeNode(node.type); case 153: - case 154: + case 263: + return getTypeFromTypeReference(node); + case 152: + return booleanType; + case 192: + return getTypeFromTypeReference(node); case 156: + return getTypeFromTypeQueryNode(node); + case 158: + case 256: + return getTypeFromArrayTypeNode(node); + case 159: + return getTypeFromTupleTypeNode(node); + case 160: + case 257: + return getTypeFromUnionTypeNode(node); + case 161: + return getTypeFromIntersectionTypeNode(node); + case 162: + case 259: + case 260: + case 267: + case 268: + case 264: + return getTypeFromTypeNode(node.type); + case 154: + case 155: + case 157: + case 265: + case 261: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 69: - case 136: + case 137: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); + case 258: + return getTypeFromJSDocTupleType(node); + case 266: + return getTypeFromJSDocVariadicType(node); default: return unknownType; } @@ -15818,6 +16360,7 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { freshTypeParameters = ts.map(signature.typeParameters, cloneTypeParameter); mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); @@ -15826,7 +16369,10 @@ var ts; tp.mapper = mapper; } } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper); + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -15884,35 +16430,34 @@ var ts; if (type.flags & 32768) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); } - if (type.flags & 134217728) { - var predicate = type.predicate; - return createPredicateType(type.symbol, cloneTypePredicate(predicate, mapper)); - } } return type; } + function instantiateIndexInfo(info, mapper) { + return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); + } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 176: case 177: + case 178: return isContextSensitiveFunctionLikeDeclaration(node); - case 168: + case 169: return ts.forEach(node.properties, isContextSensitive); - case 167: + case 168: return ts.forEach(node.elements, isContextSensitive); - case 185: + case 186: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 184: + case 185: return node.operatorToken.kind === 52 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 248: + case 249: return isContextSensitive(node.initializer); + case 145: case 144: - case 143: return isContextSensitiveFunctionLikeDeclaration(node); - case 175: + case 176: return isContextSensitive(node.expression); } return false; @@ -15991,18 +16536,48 @@ var ts; return result; } var sourceReturnType = getReturnTypeOfSignature(source); - if (targetReturnType.flags & 134217728 && targetReturnType.predicate.kind === 1) { - if (!(sourceReturnType.flags & 134217728)) { + if (target.typePredicate) { + if (source.typePredicate) { + result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes); + } + else if (ts.isIdentifierTypePredicate(target.typePredicate)) { if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); } return 0; } } - result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + else { + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + } } return result; } + function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) { + if (source.kind !== target.kind) { + if (reportErrors) { + errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return 0; + } + if (source.kind === 1) { + var sourceIdentifierPredicate = source; + var targetIdentifierPredicate = target; + if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { + if (reportErrors) { + errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return 0; + } + } + var related = compareTypes(source.type, target.type, reportErrors); + if (related === 0 && reportErrors) { + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return related; + } function isImplementationCompatibleWithOverload(implementation, overload) { var erasedSource = getErasedSignature(implementation); var erasedTarget = getErasedSignature(overload); @@ -16098,33 +16673,6 @@ var ts; return -1; } if (source.flags & 8 && target.flags & 8) { - if (source.flags & 134217728 && target.flags & 134217728) { - var sourcePredicate = source; - var targetPredicate = target; - if (sourcePredicate.predicate.kind !== targetPredicate.predicate.kind) { - if (reportErrors) { - reportError(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return 0; - } - if (sourcePredicate.predicate.kind === 1) { - var sourceIdentifierPredicate = sourcePredicate.predicate; - var targetIdentifierPredicate = targetPredicate.predicate; - if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { - if (reportErrors) { - reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return 0; - } - } - var related = isRelatedTo(sourcePredicate.predicate.type, targetPredicate.predicate.type, reportErrors, headMessage); - if (related === 0 && reportErrors) { - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return related; - } return -1; } if (source.flags & 1048576) { @@ -16216,7 +16764,7 @@ var ts; if (type.flags & 80896) { var resolved = resolveStructuredTypeMembers(type); if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || - resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + resolved.stringIndexInfo || resolved.numberIndexInfo || getPropertyOfType(type, name)) { return true; } } @@ -16231,7 +16779,7 @@ var ts; return false; } function hasExcessProperties(source, target, reportErrors) { - if (!(target.flags & 67108864) && someConstituentTypeHasKind(target, 80896)) { + if (!(target.flags & 67108864) && maybeTypeOfKind(target, 80896)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -16374,9 +16922,9 @@ var ts; if (result) { result &= signaturesRelatedTo(source, target, 1, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, 0, reportErrors); if (result) { - result &= numberIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, 1, reportErrors); } } } @@ -16416,23 +16964,23 @@ var ts; else if (!(targetProp.flags & 134217728)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 16 || targetPropFlags & 16) { + if (sourcePropFlags & 8 || targetPropFlags & 8) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 16 && targetPropFlags & 16) { + if (sourcePropFlags & 8 && targetPropFlags & 8) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 ? source : target), typeToString(sourcePropFlags & 16 ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 ? source : target), typeToString(sourcePropFlags & 8 ? target : source)); } } return 0; } } - else if (targetPropFlags & 32) { + else if (targetPropFlags & 16) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; + var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); @@ -16440,7 +16988,7 @@ var ts; return 0; } } - else if (sourcePropFlags & 32) { + else if (sourcePropFlags & 16) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -16498,36 +17046,36 @@ var ts; } var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); - if (kind === 1 && sourceSignatures.length && targetSignatures.length && - isAbstractConstructorType(source) && !isAbstractConstructorType(target)) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + if (kind === 1 && sourceSignatures.length && targetSignatures.length) { + if (isAbstractConstructorType(source) && !isAbstractConstructorType(target)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { + return 0; } - return 0; } var result = -1; var saveErrorInfo = errorInfo; outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { var t = targetSignatures_1[_i]; - if (!t.hasStringLiterals || target.flags & 262144) { - var shouldElaborateErrors = reportErrors; - for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { - var s = sourceSignatures_1[_a]; - if (!s.hasStringLiterals || source.flags & 262144) { - var related = signatureRelatedTo(s, t, shouldElaborateErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; - } - shouldElaborateErrors = false; - } + var shouldElaborateErrors = reportErrors; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; + var related = signatureRelatedTo(s, t, shouldElaborateErrors); + if (related) { + result &= related; + errorInfo = saveErrorInfo; + continue outer; } - if (shouldElaborateErrors) { - reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind)); - } - return 0; + shouldElaborateErrors = false; } + if (shouldElaborateErrors) { + reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind)); + } + return 0; } return result; } @@ -16550,75 +17098,69 @@ var ts; } return result; } - function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0, source, target); - } - var targetType = getIndexTypeOfType(target, 0); - if (targetType) { - if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { - return -1; - } - var sourceType = getIndexTypeOfType(source, 0); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + function eachPropertyRelatedTo(source, target, kind, reportErrors) { + var result = -1; + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (kind === 0 || isNumericLiteralName(prop.name)) { + var related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); + } + return 0; } - return 0; + result &= related; } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0; - } - return related; } - return -1; + return result; } - function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1, source, target); + function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { + var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors); + if (!related && reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); } - var targetType = getIndexTypeOfType(target, 1); - if (targetType) { - if ((targetType.flags & 1) && !(originalSource.flags & 16777726)) { - return -1; - } - var sourceStringType = getIndexTypeOfType(source, 0); - var sourceNumberType = getIndexTypeOfType(source, 1); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0; - } - var related; - if (sourceStringType && sourceNumberType) { - related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0; - } - return related; - } - return -1; + return related; } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { + function indexTypesRelatedTo(source, originalSource, target, kind, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(source, target, kind); + } + var targetInfo = getIndexInfoOfType(target, kind); + if (!targetInfo || ((targetInfo.type.flags & 1) && !(originalSource.flags & 16777726))) { return -1; } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); + var sourceInfo = getIndexInfoOfType(source, kind) || + kind === 1 && getIndexInfoOfType(source, 0); + if (sourceInfo) { + return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); + } + if (isObjectLiteralType(source)) { + var related = -1; + if (kind === 0) { + var sourceNumberInfo = getIndexInfoOfType(source, 1); + if (sourceNumberInfo) { + related = indexInfoRelatedTo(sourceNumberInfo, targetInfo, reportErrors); + } + } + if (related) { + related &= eachPropertyRelatedTo(source, targetInfo.type, kind, reportErrors); + } + return related; + } + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0; + } + function indexTypesIdenticalTo(source, target, indexKind) { + var targetInfo = getIndexInfoOfType(target, indexKind); + var sourceInfo = getIndexInfoOfType(source, indexKind); + if (!sourceInfo && !targetInfo) { + return -1; + } + if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) { + return isRelatedTo(sourceInfo.type, targetInfo.type); } return 0; } @@ -16641,6 +17183,26 @@ var ts; } return -1; } + function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { + if (!sourceSignature.declaration || !targetSignature.declaration) { + return true; + } + var sourceAccessibility = sourceSignature.declaration.flags & (8 | 16); + var targetAccessibility = targetSignature.declaration.flags & (8 | 16); + if (targetAccessibility === 8) { + return true; + } + if (targetAccessibility === 16 && sourceAccessibility !== 8) { + return true; + } + if (targetAccessibility !== 16 && !sourceAccessibility) { + return true; + } + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility)); + } + return false; + } } function isAbstractConstructorType(type) { if (type.flags & 65536) { @@ -16676,8 +17238,8 @@ var ts; if (sourceProp === targetProp) { return -1; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 | 32); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 | 32); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (8 | 16); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (8 | 16); if (sourcePropAccessibility !== targetPropAccessibility) { return 0; } @@ -16691,6 +17253,9 @@ var ts; return 0; } } + if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { + return 0; + } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { @@ -16778,7 +17343,8 @@ var ts; return type.flags & 4096 && type.target === globalArrayType; } function isArrayLikeType(type) { - return !(type.flags & (32 | 64)) && isTypeAssignableTo(type, anyArrayType); + return type.flags & 4096 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || + !(type.flags & (32 | 64)) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isTupleLikeType(type) { return !!getPropertyOfType(type, "0"); @@ -16789,6 +17355,11 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192); } + function isObjectLiteralType(type) { + return type.symbol && (type.symbol.flags & (4096 | 2048)) !== 0 && + getSignaturesOfType(type, 0).length === 0 && + getSignaturesOfType(type, 1).length === 0; + } function getRegularTypeOfObjectLiteral(type) { if (type.flags & 1048576) { var regularType = type.regularType; @@ -16799,8 +17370,8 @@ var ts; regularType.properties = type.properties; regularType.callSignatures = type.callSignatures; regularType.constructSignatures = type.constructSignatures; - regularType.stringIndexType = type.stringIndexType; - regularType.numberIndexType = type.numberIndexType; + regularType.stringIndexInfo = type.stringIndexInfo; + regularType.numberIndexInfo = type.numberIndexInfo; type.regularType = regularType; } return regularType; @@ -16825,22 +17396,15 @@ var ts; } members[p.name] = p; }); - var stringIndexType = getIndexTypeOfType(type, 0); - var numberIndexType = getIndexTypeOfType(type, 1); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndexInfo = getIndexInfoOfType(type, 0); + var numberIndexInfo = getIndexInfoOfType(type, 1); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); } function getWidenedType(type) { - if (type.flags & 140509184) { + if (type.flags & 6291456) { if (type.flags & (32 | 64)) { return anyType; } - if (type.flags & 134217728) { - return booleanType; - } if (type.flags & 524288) { return getWidenedTypeOfObjectLiteral(type); } @@ -16895,22 +17459,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 143: case 142: - case 141: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 139: + case 140: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 216: + case 217: + case 145: case 144: - case 143: - case 146: case 147: - case 176: + case 148: case 177: + case 178: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16976,6 +17540,7 @@ var ts; var targetStack; var depth = 0; var inferiority = 0; + var visited = {}; inferFromTypes(source, target); function isInProcess(source, target) { for (var i = 0; i < depth; i++) { @@ -16988,7 +17553,7 @@ var ts; function inferFromTypes(source, target) { if (source.flags & 16384 && target.flags & 16384 || source.flags & 32768 && target.flags & 32768) { - var matchingTypes; + var matchingTypes = void 0; for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var t = _a[_i]; if (typeIdenticalToSomeType(t, source.types)) { @@ -17029,11 +17594,6 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (source.flags & 134217728 && target.flags & 134217728) { - if (source.predicate.kind === target.predicate.kind) { - inferFromTypes(source.predicate.type, target.predicate.type); - } - } else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { var sourceTypes = source.elementTypes; var targetTypes = target.elementTypes; @@ -17044,7 +17604,7 @@ var ts; else if (target.flags & 49152) { var targetTypes = target.types; var typeParameterCount = 0; - var typeParameter; + var typeParameter = void 0; for (var _b = 0, targetTypes_2 = targetTypes; _b < targetTypes_2.length; _b++) { var t = targetTypes_2[_b]; if (t.flags & 512 && ts.contains(context.typeParameters, t)) { @@ -17079,6 +17639,11 @@ var ts; if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { return; } + var key = source.id + "," + target.id; + if (ts.hasProperty(visited, key)) { + return; + } + visited[key] = true; if (depth === 0) { sourceStack = []; targetStack = []; @@ -17089,9 +17654,7 @@ var ts; inferFromProperties(source, target); inferFromSignatures(source, target, 0); inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target, 0, 0); - inferFromIndexTypes(source, target, 1, 1); - inferFromIndexTypes(source, target, 0, 1); + inferFromIndexTypes(source, target); depth--; } } @@ -17118,14 +17681,29 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate && source.typePredicate.kind === target.typePredicate.kind) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } - function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); + function inferFromIndexTypes(source, target) { + var targetStringIndexType = getIndexTypeOfType(target, 0); + if (targetStringIndexType) { + var sourceIndexType = getIndexTypeOfType(source, 0) || + getImplicitIndexTypeOfType(source, 0); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); + inferFromTypes(sourceIndexType, targetStringIndexType); + } + } + var targetNumberIndexType = getIndexTypeOfType(target, 1); + if (targetNumberIndexType) { + var sourceIndexType = getIndexTypeOfType(source, 1) || + getIndexTypeOfType(source, 0) || + getImplicitIndexTypeOfType(source, 1); + if (sourceIndexType) { + inferFromTypes(sourceIndexType, targetNumberIndexType); } } } @@ -17199,10 +17777,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 155: + case 156: return true; case 69: - case 136: + case 137: node = node.parent; continue; default: @@ -17243,55 +17821,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 184: + case 185: return isAssignedInBinaryExpression(node); - case 214: - case 166: - return isAssignedInVariableDeclaration(node); - case 164: - case 165: + case 215: case 167: + return isAssignedInVariableDeclaration(node); + case 165: + case 166: case 168: case 169: case 170: case 171: case 172: - case 174: - case 192: + case 173: case 175: - case 182: - case 178: - case 181: - case 179: - case 180: + case 193: + case 176: case 183: - case 187: - case 185: + case 179: + case 182: + case 180: + case 181: + case 184: case 188: - case 195: + case 186: + case 189: case 196: - case 198: + case 197: case 199: case 200: case 201: case 202: case 203: case 204: - case 207: + case 205: case 208: case 209: - case 244: - case 245: case 210: + case 245: + case 246: case 211: case 212: - case 247: - case 236: + case 213: + case 248: case 237: - case 241: - case 242: case 238: + case 242: case 243: + case 239: + case 244: return ts.forEachChild(node, isAssignedIn); } return false; @@ -17301,7 +17879,7 @@ var ts; var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { - var declaration = ts.getDeclarationOfKind(symbol, 214); + var declaration = ts.getDeclarationOfKind(symbol, 215); var top_1 = declaration && getDeclarationContainer(declaration); var originalType = type; var nodeStack = []; @@ -17309,34 +17887,34 @@ var ts; var child = node; node = node.parent; switch (node.kind) { - case 199: + case 200: + case 186: case 185: - case 184: nodeStack.push({ node: node, child: child }); break; - case 251: - case 221: + case 252: + case 222: break loop; } if (node === top_1) { break; } } - var nodes; + var nodes = void 0; while (nodes = nodeStack.pop()) { var node_1 = nodes.node, child = nodes.child; switch (node_1.kind) { - case 199: + case 200: if (child !== node_1.expression) { type = narrowType(type, node_1.expression, child === node_1.thenStatement); } break; - case 185: + case 186: if (child !== node_1.condition) { type = narrowType(type, node_1.condition, child === node_1.whenTrue); } break; - case 184: + case 185: if (child === node_1.right) { if (node_1.operatorToken.kind === 51) { type = narrowType(type, node_1.left, true); @@ -17360,7 +17938,7 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 179 || expr.right.kind !== 9) { + if (expr.left.kind !== 180 || expr.right.kind !== 9) { return type; } var left = expr.left; @@ -17433,7 +18011,7 @@ var ts; } } if (!targetType) { - var constructSignatures; + var constructSignatures = void 0; if (rightType.flags & 2048) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } @@ -17467,42 +18045,30 @@ var ts; } return originalType; } - function narrowTypeByTypePredicate(type, expr, assumeTrue) { + function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { if (type.flags & 1) { return type; } - var signature = getResolvedSignature(expr); - var predicateType = getReturnTypeOfSignature(signature); - if (!predicateType || !(predicateType.flags & 134217728)) { + var signature = getResolvedSignature(callExpression); + var predicate = signature.typePredicate; + if (!predicate) { return type; } - var predicate = predicateType.predicate; if (ts.isIdentifierTypePredicate(predicate)) { - var callExpression = expr; if (callExpression.arguments[predicate.parameterIndex] && getSymbolAtTypePredicatePosition(callExpression.arguments[predicate.parameterIndex]) === symbol) { return getNarrowedType(type, predicate.type, assumeTrue); } } else { - var expression = skipParenthesizedNodes(expr.expression); - return narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue); + var invokedExpression = skipParenthesizedNodes(callExpression.expression); + return narrowTypeByThisTypePredicate(type, predicate, invokedExpression, assumeTrue); } return type; } - function narrowTypeByTypePredicateMember(type, expr, assumeTrue) { - if (type.flags & 1) { - return type; - } - var memberType = getTypeOfExpression(expr); - if (!(memberType.flags & 134217728)) { - return type; - } - return narrowTypeByThisTypePredicate(type, memberType.predicate, expr, assumeTrue); - } - function narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue) { - if (expression.kind === 170 || expression.kind === 169) { - var accessExpression = expression; + function narrowTypeByThisTypePredicate(type, predicate, invokedExpression, assumeTrue) { + if (invokedExpression.kind === 171 || invokedExpression.kind === 170) { + var accessExpression = invokedExpression; var possibleIdentifier = skipParenthesizedNodes(accessExpression.expression); if (possibleIdentifier.kind === 69 && getSymbolAtTypePredicatePosition(possibleIdentifier) === symbol) { return getNarrowedType(type, predicate.type, assumeTrue); @@ -17514,18 +18080,17 @@ var ts; expr = skipParenthesizedNodes(expr); switch (expr.kind) { case 69: - case 169: - case 136: + case 170: return getSymbolOfEntityNameOrPropertyAccessExpression(expr); } } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 171: + case 172: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 175: + case 176: return narrowType(type, expr.expression, assumeTrue); - case 184: + case 185: var operator = expr.operatorToken.kind; if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -17540,20 +18105,17 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 182: + case 183: if (expr.operator === 49) { return narrowType(type, expr.operand, !assumeTrue); } break; - case 170: - case 169: - return narrowTypeByTypePredicateMember(type, expr, assumeTrue); } return type; } } function skipParenthesizedNodes(expression) { - while (expression.kind === 175) { + while (expression.kind === 176) { expression = expression.expression; } return expression; @@ -17562,23 +18124,37 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 177) { + if (container.kind === 178) { 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); } } - if (node.parserContextFlags & 8) { - getNodeLinks(container).flags |= 4096; - getNodeLinks(node).flags |= 2048; + if (node.flags & 33554432) { + getNodeLinks(container).flags |= 8192; } } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); } + var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); + if (languageVersion === 2 + && localOrExportSymbol.flags & 32 + && localOrExportSymbol.valueDeclaration.kind === 218 + && ts.nodeIsDecorated(localOrExportSymbol.valueDeclaration)) { + var container = ts.getContainingClass(node); + while (container !== undefined) { + if (container === localOrExportSymbol.valueDeclaration && container.name !== node) { + getNodeLinks(container).flags |= 524288; + getNodeLinks(node).flags |= 1048576; + break; + } + container = ts.getContainingClass(container); + } + } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); - checkBlockScopedBindingCapturedInLoop(node, symbol); - return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); + checkNestedBlockScopedBinding(node, symbol); + return getNarrowedTypeOfSymbol(localOrExportSymbol, node); } function isInsideFunction(node, threshold) { var current = node; @@ -17590,42 +18166,67 @@ var ts; } return false; } - function checkBlockScopedBindingCapturedInLoop(node, symbol) { + function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 247) { + symbol.valueDeclaration.parent.kind === 248) { return; } - var container; - if (symbol.flags & 32) { - container = getClassLikeDeclarationOfSymbol(symbol).parent; - } - else { - container = symbol.valueDeclaration; - while (container.kind !== 215) { - container = container.parent; - } - container = container.parent; - if (container.kind === 196) { - container = container.parent; - } - } - var inFunction = isInsideFunction(node.parent, container); + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + var usedInFunction = isInsideFunction(node.parent, container); var current = container; + var containedInIterationStatement = false; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { if (ts.isIterationStatement(current, false)) { - if (inFunction) { - getNodeLinks(current).flags |= 65536; - } - getNodeLinks(symbol.valueDeclaration).flags |= 16384; + containedInIterationStatement = true; break; } current = current.parent; } + if (containedInIterationStatement) { + if (usedInFunction) { + getNodeLinks(current).flags |= 65536; + } + if (container.kind === 203 && + ts.getAncestor(symbol.valueDeclaration, 216).parent === container && + isAssignedInBodyOfForStatement(node, container)) { + getNodeLinks(symbol.valueDeclaration).flags |= 2097152; + } + getNodeLinks(symbol.valueDeclaration).flags |= 262144; + } + if (usedInFunction) { + getNodeLinks(symbol.valueDeclaration).flags |= 131072; + } + } + function isAssignedInBodyOfForStatement(node, container) { + var current = node; + while (current.parent.kind === 176) { + current = current.parent; + } + var isAssigned = false; + if (current.parent.kind === 185) { + isAssigned = current.parent.left === current && ts.isAssignmentOperator(current.parent.operatorToken.kind); + } + if ((current.parent.kind === 183 || current.parent.kind === 184)) { + var expr = current.parent; + isAssigned = expr.operator === 41 || expr.operator === 42; + } + if (!isAssigned) { + return false; + } + while (current !== container) { + if (current === container.statement) { + return true; + } + else { + current = current.parent; + } + } + return false; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 142 || container.kind === 145) { + if (container.kind === 143 || container.kind === 146) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -17633,32 +18234,65 @@ var ts; getNodeLinks(container).flags |= 4; } } + function findFirstSuperCall(n) { + if (ts.isSuperCallExpression(n)) { + return n; + } + else if (ts.isFunctionLike(n)) { + return undefined; + } + return ts.forEachChild(n, findFirstSuperCall); + } + function getSuperCallInConstructor(constructor) { + var links = getNodeLinks(constructor); + if (links.hasSuperCall === undefined) { + links.superCall = findFirstSuperCall(constructor.body); + links.hasSuperCall = links.superCall ? true : false; + } + return links.superCall; + } + function classDeclarationExtendsNull(classDecl) { + var classSymbol = getSymbolOfNode(classDecl); + var classInstanceType = getDeclaredTypeOfSymbol(classSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType); + return baseConstructorType === nullType; + } function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 177) { + if (container.kind === 146) { + var containingClassDecl = container.parent; + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { + var superCall = getSuperCallInConstructor(container); + if (!superCall || superCall.end > node.pos) { + error(node, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); + } + } + } + if (container.kind === 178) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 221: + case 222: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 220: + case 221: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 145: + case 146: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 143: case 142: - case 141: - if (container.flags & 64) { + if (container.flags & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 137: + case 138: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -17667,36 +18301,51 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 64 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 32 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } - if (ts.isInJavaScriptFile(node) && container.kind === 176) { - if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { - var className = container.parent - .left - .expression - .expression; - var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) { - return getInferredClassType(classSymbol); + if (ts.isInJavaScriptFile(node)) { + var type = getTypeForThisExpressionFromJSDoc(container); + if (type && type !== unknownType) { + return type; + } + if (container.kind === 177) { + if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { + var className = container.parent + .left + .expression + .expression; + var classSymbol = checkExpression(className).symbol; + if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) { + return getInferredClassType(classSymbol); + } } } } return anyType; } + function getTypeForThisExpressionFromJSDoc(node) { + var typeTag = ts.getJSDocTypeTag(node); + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 265) { + var jsDocFunctionType = typeTag.typeExpression.type; + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 268) { + return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); + } + } + } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 139) { + if (n.kind === 140) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 171 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 172 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 177) { + while (container && container.kind === 178) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -17705,16 +18354,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 137) { + while (current && current !== container && current.kind !== 138) { current = current.parent; } - if (current && current.kind === 137) { + if (current && current.kind === 138) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 168)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 169)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -17722,17 +18371,25 @@ var ts; } return unknownType; } - if ((container.flags & 64) || isCallExpression) { + if ((container.flags & 32) || isCallExpression) { nodeCheckFlag = 512; } else { nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; + if (container.kind === 145 && container.flags & 256) { + if (ts.isSuperPropertyOrElementAccess(node.parent) && isAssignmentTarget(node.parent)) { + getNodeLinks(container).flags |= 4096; + } + else { + getNodeLinks(container).flags |= 2048; + } + } if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 168) { + if (container.parent.kind === 169) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -17750,7 +18407,7 @@ var ts; } return unknownType; } - if (container.kind === 145 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 146 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -17762,24 +18419,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 145; + return container.kind === 146; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 168) { - if (container.flags & 64) { - return container.kind === 144 || - container.kind === 143 || - container.kind === 146 || - container.kind === 147; + if (ts.isClassLike(container.parent) || container.parent.kind === 169) { + if (container.flags & 32) { + return container.kind === 145 || + container.kind === 144 || + container.kind === 147 || + container.kind === 148; } else { - return container.kind === 144 || - container.kind === 143 || - container.kind === 146 || + return container.kind === 145 || + container.kind === 144 || container.kind === 147 || + container.kind === 148 || + container.kind === 143 || container.kind === 142 || - container.kind === 141 || - container.kind === 145; + container.kind === 146; } } } @@ -17814,7 +18471,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 139) { + if (declaration.kind === 140) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17847,7 +18504,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 139 && node.parent.initializer === node) { + if (node.parent.kind === 140 && node.parent.initializer === node) { return true; } node = node.parent; @@ -17856,8 +18513,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 145 || - functionDecl.kind === 146 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 147))) { + functionDecl.kind === 146 || + functionDecl.kind === 147 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 148))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -17876,7 +18533,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 173) { + if (template.parent.kind === 174) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17942,9 +18599,6 @@ var ts; function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } - function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); - } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); if (isInsideWithStatementBody(node)) { @@ -17987,13 +18641,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 241) { + if (attribute.kind === 242) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 242) { + else if (attribute.kind === 243) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -18011,40 +18665,40 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 214: - case 139: + case 215: + case 140: + case 143: case 142: - case 141: - case 166: - return getContextualTypeForInitializerExpression(node); - case 177: - case 207: - return getContextualTypeForReturnExpression(node); - case 187: - return getContextualTypeForYieldOperand(parent); - case 171: - case 172: - return getContextualTypeForArgument(parent, node); - case 174: - case 192: - return getTypeFromTypeNode(parent.type); - case 184: - return getContextualTypeForBinaryOperand(node); - case 248: - return getContextualTypeForObjectLiteralElement(parent); case 167: - return getContextualTypeForElementExpression(node); - case 185: - return getContextualTypeForConditionalOperand(node); - case 193: - ts.Debug.assert(parent.parent.kind === 186); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 178: + case 208: + return getContextualTypeForReturnExpression(node); + case 188: + return getContextualTypeForYieldOperand(parent); + case 172: + case 173: + return getContextualTypeForArgument(parent, node); case 175: + case 193: + return getTypeFromTypeNode(parent.type); + case 185: + return getContextualTypeForBinaryOperand(node); + case 249: + return getContextualTypeForObjectLiteralElement(parent); + case 168: + return getContextualTypeForElementExpression(node); + case 186: + return getContextualTypeForConditionalOperand(node); + case 194: + ts.Debug.assert(parent.parent.kind === 187); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 176: return getContextualType(parent); - case 243: + case 244: return getContextualType(parent); - case 241: case 242: + case 243: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -18059,7 +18713,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 176 || node.kind === 177; + return node.kind === 177 || node.kind === 178; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -18067,7 +18721,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getApparentTypeOfContextualType(node); @@ -18107,13 +18761,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 184 && parent.operatorToken.kind === 56 && parent.left === node) { + if (parent.kind === 185 && parent.operatorToken.kind === 56 && parent.left === node) { return true; } - if (parent.kind === 248) { + if (parent.kind === 249) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 167) { + if (parent.kind === 168) { return isAssignmentTarget(parent); } return false; @@ -18123,8 +18777,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 166 && !!node.initializer) || - (node.kind === 184 && node.operatorToken.kind === 56); + return (node.kind === 167 && !!node.initializer) || + (node.kind === 185 && node.operatorToken.kind === 56); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -18133,7 +18787,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 188) { + if (inDestructuringPattern && e.kind === 189) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -18145,7 +18799,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 188; + hasSpreadElement = hasSpreadElement || e.kind === 189; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -18156,7 +18810,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 165 || pattern.kind === 167)) { + if (pattern && (pattern.kind === 166 || pattern.kind === 168)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -18164,7 +18818,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 190) { + if (patternElement.kind !== 191) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -18179,13 +18833,13 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 137 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 138 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); } function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); + return isTypeAny(type) || isTypeOfKind(type, kind); } function isNumericLiteralName(name) { return (+name).toString() === name; @@ -18203,6 +18857,16 @@ var ts; } return links.resolvedType; } + function getObjectLiteralIndexInfo(node, properties, kind) { + var propTypes = []; + for (var i = 0; i < properties.length; i++) { + if (kind === 0 || isNumericName(node.properties[i].name)) { + propTypes.push(getTypeOfSymbol(properties[i])); + } + } + var unionType = propTypes.length ? getUnionType(propTypes) : undefinedType; + return createIndexInfo(unionType, false); + } function checkObjectLiteral(node, contextualMapper) { var inDestructuringPattern = isAssignmentTarget(node); checkGrammarObjectLiteralExpression(node, inDestructuringPattern); @@ -18210,31 +18874,33 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 164 || contextualType.pattern.kind === 168); + (contextualType.pattern.kind === 165 || contextualType.pattern.kind === 169); var typeFlags = 0; var patternWithComputedProperties = false; + var hasComputedStringProperty = false; + var hasComputedNumberProperty = false; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 248 || - memberDecl.kind === 249 || + if (memberDecl.kind === 249 || + memberDecl.kind === 250 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 248) { + if (memberDecl.kind === 249) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 144) { + else if (memberDecl.kind === 145) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 249); + ts.Debug.assert(memberDecl.kind === 250); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 248 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 249 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 249 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 250 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -18261,10 +18927,18 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 146 || memberDecl.kind === 147); + ts.Debug.assert(memberDecl.kind === 147 || memberDecl.kind === 148); checkAccessorDeclaration(memberDecl); } - if (!ts.hasDynamicName(memberDecl)) { + if (ts.hasDynamicName(memberDecl)) { + if (isNumericName(memberDecl.name)) { + hasComputedNumberProperty = true; + } + else { + hasComputedStringProperty = true; + } + } + else { propertiesTable[member.name] = member; } propertiesArray.push(member); @@ -18281,33 +18955,15 @@ var ts; } } } - var stringIndexType = getIndexType(0); - var numberIndexType = getIndexType(1); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064) | (patternWithComputedProperties ? 67108864 : 0); if (inDestructuringPattern) { result.pattern = node; } return result; - function getIndexType(kind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - var propTypes = []; - for (var i = 0; i < propertiesArray.length; i++) { - var propertyDecl = node.properties[i]; - if (kind === 0 || isNumericName(propertyDecl.name)) { - var type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, type)) { - propTypes.push(type); - } - } - } - var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= result_1.flags; - return result_1; - } - return undefined; - } } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -18315,17 +18971,17 @@ var ts; } function checkJsxElement(node) { checkJsxOpeningLikeElement(node.openingElement); - getJsxElementTagSymbol(node.closingElement); + getJsxTagSymbol(node.closingElement); for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 243: + case 244: checkJsxExpression(child); break; - case 236: + case 237: checkJsxElement(child); break; - case 237: + case 238: checkJsxSelfClosingElement(child); break; } @@ -18336,7 +18992,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 136) { + if (tagName.kind === 137) { return false; } else { @@ -18399,68 +19055,43 @@ var ts; } return jsxTypes[name]; } - function getJsxElementTagSymbol(node) { + function getJsxTagSymbol(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicTagSymbol(node); + } + else { + return checkExpression(node.tagName).symbol; + } + } + function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - links.resolvedSymbol = lookupIntrinsicTag(node); - } - else { - links.resolvedSymbol = lookupClassTag(node); - } - } - return links.resolvedSymbol; - function lookupIntrinsicTag(node) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); if (intrinsicProp) { links.jsxFlags |= 1; - return intrinsicProp; + return links.resolvedSymbol = intrinsicProp; } var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); if (indexSignatureType) { links.jsxFlags |= 2; - return intrinsicElementsType.symbol; + return links.resolvedSymbol = intrinsicElementsType.symbol; } error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); - return unknownSymbol; + return links.resolvedSymbol = unknownSymbol; } else { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } - return unknownSymbol; - } - } - function lookupClassTag(node) { - var valueSymbol = resolveJsxTagName(node); - if (valueSymbol && valueSymbol !== unknownSymbol) { - links.jsxFlags |= 4; - if (valueSymbol.flags & 8388608) { - markAliasSymbolAsReferenced(valueSymbol); - } - } - return valueSymbol || unknownSymbol; - } - function resolveJsxTagName(node) { - if (node.tagName.kind === 69) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - return sym.exportSymbol || sym; - } - else { - return checkQualifiedName(node.tagName).symbol; + return links.resolvedSymbol = unknownSymbol; } } + return links.resolvedSymbol; } function getJsxElementInstanceType(node) { - ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); - var classSymbol = getJsxElementTagSymbol(node); - if (classSymbol === unknownSymbol) { - return anyType; - } - var valueType = getTypeOfSymbol(classSymbol); + var valueType = checkExpression(node.tagName); if (isTypeAny(valueType)) { return anyType; } @@ -18498,12 +19129,20 @@ var ts; function getJsxElementAttributesType(node) { var links = getNodeLinks(node); if (!links.resolvedJsxType) { - var sym = getJsxElementTagSymbol(node); - if (links.jsxFlags & 4) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1) { + return links.resolvedJsxType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0).type; + } + } + else { var elemInstanceType = getJsxElementInstanceType(node); var elemClassType = getJsxGlobalElementClassType(); if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { - var elemType = getTypeOfSymbol(sym); + var elemType = checkExpression(node.tagName); var callSignatures = elemType && getSignaturesOfType(elemType, 0); var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); @@ -18563,15 +19202,7 @@ var ts; } } } - else if (links.jsxFlags & 1) { - return links.resolvedJsxType = getTypeOfSymbol(sym); - } - else if (links.jsxFlags & 2) { - return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0); - } - else { - return links.resolvedJsxType = anyType; - } + return links.resolvedJsxType = unknownType; } return links.resolvedJsxType; } @@ -18613,11 +19244,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 241) { + if (node.attributes[i].kind === 242) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 242); + ts.Debug.assert(node.attributes[i].kind === 243); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -18643,19 +19274,19 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 142; + return s.valueDeclaration ? s.valueDeclaration.kind : 143; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 8 | 64 : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; } function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); if (left.kind === 95) { - var errorNode = node.kind === 169 ? + var errorNode = node.kind === 170 ? node.name : node.right; - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 144) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 145) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -18664,12 +19295,12 @@ var ts; return false; } } - if (!(flags & (16 | 32))) { + if (!(flags & (8 | 16))) { return true; } var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - if (flags & 16) { + if (flags & 8) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -18683,7 +19314,7 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); return false; } - if (flags & 64) { + if (flags & 32) { return true; } if (type.flags & 33554432) { @@ -18724,7 +19355,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 169 + var left = node.kind === 170 ? node.expression : node.left; var type = checkExpression(left); @@ -18738,7 +19369,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 215) { + if (initializer.kind === 216) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -18760,7 +19391,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 203 && + if (node.kind === 204 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -18776,7 +19407,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 172 && node.parent.expression === node) { + if (node.parent.kind === 173 && 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); @@ -18814,14 +19445,16 @@ var ts; } if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { - var numberIndexType = getIndexTypeOfType(objectType, 1); - if (numberIndexType) { - return numberIndexType; + var numberIndexInfo = getIndexInfoOfType(objectType, 1); + if (numberIndexInfo) { + getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; + return numberIndexInfo.type; } } - var stringIndexType = getIndexTypeOfType(objectType, 0); - if (stringIndexType) { - return stringIndexType; + var stringIndexInfo = getIndexInfoOfType(objectType, 0); + if (stringIndexInfo) { + getNodeLinks(node).resolvedIndexInfo = stringIndexInfo; + return stringIndexInfo.type; } if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { error(node, getIndexTypeOfType(objectType, 1) ? @@ -18837,7 +19470,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 170 || indexArgumentExpression.kind === 169) { + if (indexArgumentExpression.kind === 171 || indexArgumentExpression.kind === 170) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -18880,10 +19513,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 173) { + if (node.kind === 174) { checkExpression(node.template); } - else if (node.kind !== 140) { + else if (node.kind !== 141) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -18905,19 +19538,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_5 = signature.declaration && signature.declaration.parent; + var parent_6 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_5 === lastParent) { + if (lastParent && parent_6 === lastParent) { index++; } else { - lastParent = parent_5; + lastParent = parent_6; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_5; + lastParent = parent_6; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -18934,7 +19567,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 188) { + if (arg && arg.kind === 189) { return i; } } @@ -18946,11 +19579,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 173) { + if (node.kind === 174) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 186) { + if (tagExpression.template.kind === 187) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -18962,7 +19595,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 140) { + else if (node.kind === 141) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -18970,7 +19603,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 172); + ts.Debug.assert(callExpression.kind === 173); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -18996,7 +19629,7 @@ var ts; if (type.flags & 80896) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { return resolved.callSignatures[0]; } } @@ -19023,7 +19656,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 !== 190) { + if (arg === undefined || arg.kind !== 191) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -19072,7 +19705,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 !== 190) { + if (arg === undefined || arg.kind !== 191) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -19091,16 +19724,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 173) { + if (node.kind === 174) { var template = node.template; args = [undefined]; - if (template.kind === 186) { + if (template.kind === 187) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 140) { + else if (node.kind === 141) { return undefined; } else { @@ -19109,21 +19742,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 140) { + if (node.kind === 141) { switch (node.parent.kind) { - case 217: - case 189: + case 218: + case 190: return 1; - case 142: + case 143: return 2; - case 144: - case 146: + case 145: case 147: + case 148: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 139: + case 140: return 3; } } @@ -19132,50 +19765,50 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 217) { + if (node.kind === 218) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 139) { + if (node.kind === 140) { node = node.parent; - if (node.kind === 145) { + if (node.kind === 146) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 142 || - node.kind === 144 || - node.kind === 146 || - node.kind === 147) { + if (node.kind === 143 || + node.kind === 145 || + node.kind === 147 || + node.kind === 148) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 217) { + if (node.kind === 218) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 139) { + if (node.kind === 140) { node = node.parent; - if (node.kind === 145) { + if (node.kind === 146) { return anyType; } } - if (node.kind === 142 || - node.kind === 144 || - node.kind === 146 || - node.kind === 147) { + if (node.kind === 143 || + node.kind === 145 || + node.kind === 147 || + node.kind === 148) { var element = node; switch (element.name.kind) { case 69: case 8: case 9: return getStringLiteralTypeForText(element.name.text); - case 137: + case 138: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216)) { + if (isTypeOfKind(nameType, 16777216)) { return nameType; } else { @@ -19190,20 +19823,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 217) { + if (node.kind === 218) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 139) { + if (node.kind === 140) { return numberType; } - if (node.kind === 142) { + if (node.kind === 143) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144 || - node.kind === 146 || - node.kind === 147) { + if (node.kind === 145 || + node.kind === 147 || + node.kind === 148) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -19224,26 +19857,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 140) { + if (node.kind === 141) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 173) { + else if (argIndex === 0 && node.kind === 174) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 140 || - (argIndex === 0 && node.kind === 173)) { + if (node.kind === 141 || + (argIndex === 0 && node.kind === 174)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 140) { + if (node.kind === 141) { return node.expression; } - else if (argIndex === 0 && node.kind === 173) { + else if (argIndex === 0 && node.kind === 174) { return node.template; } else { @@ -19251,8 +19884,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 173; - var isDecorator = node.kind === 140; + var isTaggedTemplate = node.kind === 174; + var isDecorator = node.kind === 141; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -19299,8 +19932,8 @@ var ts; } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - var typeArguments_1 = node.typeArguments; - checkTypeArguments(candidateForTypeArgumentError, typeArguments_1, ts.map(typeArguments_1, getTypeFromTypeNode), true, headMessage); + var typeArguments_2 = node.typeArguments; + checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNode), true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -19399,8 +20032,10 @@ var ts; var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); - return resolveCall(node, baseConstructors, candidatesOutArray); + if (baseTypeNode) { + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); + } } return resolveUntypedCall(node); } @@ -19453,6 +20088,9 @@ var ts; } var constructSignatures = getSignaturesOfType(expressionType, 1); if (constructSignatures.length) { + if (!isConstructorAccessible(node, constructSignatures[0])) { + return resolveErrorCall(node); + } return resolveCall(node, constructSignatures, candidatesOutArray); } var callSignatures = getSignaturesOfType(expressionType, 0); @@ -19466,6 +20104,28 @@ var ts; error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); return resolveErrorCall(node); } + function isConstructorAccessible(node, signature) { + if (!signature || !signature.declaration) { + return true; + } + var declaration = signature.declaration; + var flags = declaration.flags; + if (!(flags & (8 | 16))) { + return true; + } + var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); + var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol); + if (!isNodeWithinClass(node, declaringClassDeclaration)) { + if (flags & 8) { + error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); + } + if (flags & 16) { + error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); + } + return false; + } + return true; + } function resolveTaggedTemplateExpression(node, candidatesOutArray) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); @@ -19484,16 +20144,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 217: - case 189: + case 218: + case 190: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 139: + case 140: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 144: - case 146: + case 145: case 147: + case 148: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -19509,7 +20169,7 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorInfo; + var errorInfo = void 0; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); @@ -19521,16 +20181,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 171) { + if (node.kind === 172) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 172) { + else if (node.kind === 173) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 173) { + else if (node.kind === 174) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 140) { + else if (node.kind === 141) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -19552,12 +20212,13 @@ var ts; if (node.expression.kind === 95) { return voidType; } - if (node.kind === 172) { + if (node.kind === 173) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 145 && - declaration.kind !== 149 && - declaration.kind !== 154) { + declaration.kind !== 146 && + declaration.kind !== 150 && + declaration.kind !== 155 && + !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16)) { return getInferredClassType(funcSymbol); @@ -19568,7 +20229,7 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, true)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -19581,8 +20242,8 @@ var ts; var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); - var bothAreStringLike = someConstituentTypeHasKind(targetType, 258) && - someConstituentTypeHasKind(widenedType, 258); + var bothAreStringLike = maybeTypeOfKind(targetType, 258) && + maybeTypeOfKind(widenedType, 258); if (!bothAreStringLike && !(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } @@ -19611,7 +20272,7 @@ var ts; if (ts.isBindingPattern(node.name)) { for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 190) { + if (element.kind !== 191) { if (element.name.kind === 69) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } @@ -19630,6 +20291,13 @@ var ts; inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } + function getReturnTypeFromJSDocComment(func) { + var returnTag = ts.getJSDocReturnTag(func); + if (returnTag && returnTag.typeExpression) { + return getTypeFromTypeNode(returnTag.typeExpression.type); + } + return undefined; + } function createPromiseType(promisedType) { var globalPromiseType = getGlobalPromiseType(); if (globalPromiseType !== emptyGenericType) { @@ -19645,14 +20313,14 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 195) { + if (func.body.kind !== 196) { 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); } } else { - var types; + var types = void 0; var funcIsGenerator = !!func.asteriskToken; if (funcIsGenerator) { types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); @@ -19688,7 +20356,7 @@ var ts; } else { error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; + return getUnionType(types); } } if (funcIsGenerator) { @@ -19747,13 +20415,13 @@ var ts; if (!produceDiagnostics) { return; } - if (returnType === voidType || isTypeAny(returnType)) { + if (returnType && maybeTypeOfKind(returnType, 1 | 16)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 195 || !(func.flags & 524288)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 196 || !(func.flags & 32768)) { return; } - var hasExplicitReturn = func.flags & 1048576; + var hasExplicitReturn = func.flags & 65536; if (returnType && !hasExplicitReturn) { error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } @@ -19770,9 +20438,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 176) { + if (!hasGrammarError && node.kind === 177) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -19805,14 +20473,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 144 && node.kind !== 143) { + if (produceDiagnostics && node.kind !== 145 && node.kind !== 144) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 144 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -19822,7 +20490,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 195) { + if (node.body.kind === 196) { checkSourceElement(node.body); } else { @@ -19846,59 +20514,62 @@ var ts; } return true; } - function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { - function findSymbol(n) { - var symbol = getNodeLinks(n).resolvedSymbol; - return symbol && getExportSymbolOfValueSymbolIfExported(symbol); + function isReadonlySymbol(symbol) { + return symbol.flags & 4 && (getDeclarationFlagsFromSymbol(symbol) & 64) !== 0 || + symbol.flags & 3 && (getDeclarationFlagsFromSymbol(symbol) & 2048) !== 0 || + symbol.flags & 98304 && !(symbol.flags & 65536) || + (symbol.flags & 8) !== 0; + } + function isReferenceToReadonlyEntity(expr, symbol) { + if (isReadonlySymbol(symbol)) { + if (symbol.flags & 4 && + (expr.kind === 170 || expr.kind === 171) && + expr.expression.kind === 97) { + var func = ts.getContainingFunction(expr); + return !(func && func.kind === 146 && func.parent === symbol.valueDeclaration.parent); + } + return true; } - function isReferenceOrErrorExpression(n) { - switch (n.kind) { - case 69: { - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; + return false; + } + function isReferenceThroughNamespaceImport(expr) { + if (expr.kind === 170 || expr.kind === 171) { + var node = skipParenthesizedNodes(expr.expression); + if (node.kind === 69) { + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol.flags & 8388608) { + var declaration = getDeclarationOfAliasSymbol(symbol); + return declaration && declaration.kind === 228; } - case 169: { - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; - } - case 170: - return true; - case 175: - return isReferenceOrErrorExpression(n.expression); - default: - return false; } } - function isConstVariableReference(n) { - switch (n.kind) { - case 69: - case 169: { - var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384) !== 0; - } - case 170: { - var index = n.argumentExpression; - var symbol = findSymbol(n.expression); - 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) & 16384) !== 0; - } + return false; + } + function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { + var node = skipParenthesizedNodes(expr); + if (node.kind !== 69 && node.kind !== 170 && node.kind !== 171) { + error(expr, invalidReferenceMessage); + return false; + } + var links = getNodeLinks(node); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol) { + if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { + if (node.kind === 69 && !(symbol.flags & 3)) { + error(expr, invalidReferenceMessage); return false; } - case 175: - return isConstVariableReference(n.expression); - default: + if (isReferenceToReadonlyEntity(node, symbol) || isReferenceThroughNamespaceImport(node)) { + error(expr, constantVariableMessage); return false; + } } } - if (!isReferenceOrErrorExpression(n)) { - error(n, invalidReferenceMessage); - return false; - } - if (isConstVariableReference(n)) { - error(n, constantVariableMessage); - return false; + else if (node.kind === 171) { + if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { + error(expr, constantVariableMessage); + return false; + } } return true; } @@ -19916,7 +20587,7 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.parserContextFlags & 8)) { + if (!(node.flags & 33554432)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -19932,7 +20603,7 @@ var ts; case 35: case 36: case 50: - if (someConstituentTypeHasKind(operandType, 16777216)) { + if (maybeTypeOfKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; @@ -19942,7 +20613,7 @@ var ts; case 42: 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } @@ -19952,40 +20623,48 @@ var ts; var operandType = checkExpression(node.operand); 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } - function someConstituentTypeHasKind(type, kind) { + function maybeTypeOfKind(type, kind) { if (type.flags & kind) { return true; } if (type.flags & 49152) { var types = type.types; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var current = types_10[_i]; - if (current.flags & kind) { + var t = types_10[_i]; + if (maybeTypeOfKind(t, kind)) { return true; } } - return false; } return false; } - function allConstituentTypesHaveKind(type, kind) { + function isTypeOfKind(type, kind) { if (type.flags & kind) { return true; } - if (type.flags & 49152) { + if (type.flags & 16384) { var types = type.types; for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var current = types_11[_i]; - if (!(current.flags & kind)) { + var t = types_11[_i]; + if (!isTypeOfKind(t, kind)) { return false; } } return true; } + if (type.flags & 32768) { + var types = type.types; + for (var _a = 0, types_12 = types; _a < types_12.length; _a++) { + var t = types_12[_a]; + if (isTypeOfKind(t, kind)) { + return true; + } + } + } return false; } function isConstEnumObjectType(type) { @@ -19995,7 +20674,7 @@ var ts; return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 16777726)) { + if (isTypeOfKind(leftType, 16777726)) { error(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))) { @@ -20016,22 +20695,22 @@ var ts; var properties = node.properties; for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var p = properties_3[_i]; - if (p.kind === 248 || p.kind === 249) { - var name_13 = p.name; - if (name_13.kind === 137) { - checkComputedPropertyName(name_13); + if (p.kind === 249 || p.kind === 250) { + var name_12 = p.name; + if (name_12.kind === 138) { + checkComputedPropertyName(name_12); } - if (isComputedNonLiteralName(name_13)) { + if (isComputedNonLiteralName(name_12)) { continue; } - var text = getTextOfPropertyName(name_13); + var text = getTextOfPropertyName(name_12); var type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, text) || isNumericLiteralName(text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - if (p.kind === 249) { + if (p.kind === 250) { checkDestructuringAssignment(p, type); } else { @@ -20039,7 +20718,7 @@ var ts; } } else { - error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); + error(name_12, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_12)); } } else { @@ -20053,8 +20732,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 190) { - if (e.kind !== 188) { + if (e.kind !== 191) { + if (e.kind !== 189) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -20079,7 +20758,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 184 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 185 && restExpression.operatorToken.kind === 56) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -20093,7 +20772,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 249) { + if (exprOrAssignment.kind === 250) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); @@ -20103,21 +20782,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 184 && target.operatorToken.kind === 56) { + if (target.kind === 185 && target.operatorToken.kind === 56) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 168) { + if (target.kind === 169) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 167) { + if (target.kind === 168) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) { checkTypeAssignableTo(sourceType, targetType, target, undefined); } return sourceType; @@ -20127,7 +20806,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 168 || left.kind === 167)) { + if (operator === 56 && (left.kind === 169 || left.kind === 168)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -20159,7 +20838,7 @@ var ts; leftType = rightType; if (rightType.flags & (32 | 64)) rightType = leftType; - var suggestedOperator; + var suggestedOperator = void 0; if ((leftType.flags & 8) && (rightType.flags & 8) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { @@ -20179,12 +20858,12 @@ var ts; leftType = rightType; if (rightType.flags & (32 | 64)) rightType = leftType; - var resultType; - if (allConstituentTypesHaveKind(leftType, 132) && allConstituentTypesHaveKind(rightType, 132)) { + var resultType = void 0; + if (isTypeOfKind(leftType, 132) && isTypeOfKind(rightType, 132)) { resultType = numberType; } else { - if (allConstituentTypesHaveKind(leftType, 258) || allConstituentTypesHaveKind(rightType, 258)) { + if (isTypeOfKind(leftType, 258) || isTypeOfKind(rightType, 258)) { resultType = stringType; } else if (isTypeAny(leftType) || isTypeAny(rightType)) { @@ -20213,7 +20892,7 @@ var ts; case 31: case 32: case 33: - if (someConstituentTypeHasKind(leftType, 258) && someConstituentTypeHasKind(rightType, 258)) { + if (maybeTypeOfKind(leftType, 258) && maybeTypeOfKind(rightType, 258)) { return booleanType; } if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { @@ -20235,8 +20914,8 @@ var ts; return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? left : - someConstituentTypeHasKind(rightType, 16777216) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 16777216) ? left : + maybeTypeOfKind(rightType, 16777216) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -20261,7 +20940,7 @@ var ts; } function checkAssignmentOperator(valueType) { if (produceDiagnostics && operator >= 56 && operator <= 68) { - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); if (ok) { checkTypeAssignableTo(valueType, leftType, left, undefined); } @@ -20288,7 +20967,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.parserContextFlags & 2) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8388608) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -20299,7 +20978,7 @@ var ts; var func = ts.getContainingFunction(node); if (func && func.asteriskToken) { var expressionType = checkExpressionCached(node.expression, undefined); - var expressionElementType; + var expressionElementType = void 0; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); @@ -20351,14 +21030,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 137) { + if (node.name.kind === 138) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 137) { + if (node.name.kind === 138) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -20381,7 +21060,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 136) { + if (node.kind === 137) { type = checkQualifiedName(node); } else { @@ -20389,9 +21068,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 169 && node.parent.expression === node) || - (node.parent.kind === 170 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 136) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 170 && node.parent.expression === node) || + (node.parent.kind === 171 && node.parent.expression === node) || + ((node.kind === 69 || node.kind === 137) && 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); } @@ -20417,7 +21096,7 @@ var ts; return booleanType; case 8: return checkNumericLiteral(node); - case 186: + case 187: return checkTemplateExpression(node); case 9: return checkStringLiteralExpression(node); @@ -20425,58 +21104,58 @@ var ts; return stringType; case 10: return globalRegExpType; - case 167: - return checkArrayLiteral(node, contextualMapper); case 168: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 169: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 170: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 171: + return checkIndexedAccess(node); case 172: - return checkCallExpression(node); case 173: - return checkTaggedTemplateExpression(node); - case 175: - return checkExpression(node.expression, contextualMapper); - case 189: - return checkClassExpression(node); - case 176: - case 177: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 179: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 174: - case 192: - return checkAssertion(node); - case 178: - return checkDeleteExpression(node); - case 180: - return checkVoidExpression(node); - case 181: - return checkAwaitExpression(node); - case 182: - return checkPrefixUnaryExpression(node); - case 183: - return checkPostfixUnaryExpression(node); - case 184: - return checkBinaryExpression(node, contextualMapper); - case 185: - return checkConditionalExpression(node, contextualMapper); - case 188: - return checkSpreadElementExpression(node, contextualMapper); + return checkTaggedTemplateExpression(node); + case 176: + return checkExpression(node.expression, contextualMapper); case 190: + return checkClassExpression(node); + case 177: + case 178: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 180: + return checkTypeOfExpression(node); + case 175: + case 193: + return checkAssertion(node); + case 179: + return checkDeleteExpression(node); + case 181: + return checkVoidExpression(node); + case 182: + return checkAwaitExpression(node); + case 183: + return checkPrefixUnaryExpression(node); + case 184: + return checkPostfixUnaryExpression(node); + case 185: + return checkBinaryExpression(node, contextualMapper); + case 186: + return checkConditionalExpression(node, contextualMapper); + case 189: + return checkSpreadElementExpression(node, contextualMapper); + case 191: return undefinedType; - case 187: + case 188: return checkYieldExpression(node); - case 243: + case 244: return checkJsxExpression(node); - case 236: - return checkJsxElement(node); case 237: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 238: + return checkJsxSelfClosingElement(node); + case 239: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -20495,9 +21174,9 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 56) { + if (node.flags & 28) { func = ts.getContainingFunction(node); - if (!(func.kind === 145 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 146 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -20512,9 +21191,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 144 || - node.kind === 216 || - node.kind === 176; + return node.kind === 145 || + node.kind === 217 || + node.kind === 177; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -20531,18 +21210,18 @@ var ts; function checkTypePredicate(node) { var parent = getTypePredicateParent(node); if (!parent) { + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; } - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(parent)); - if (!returnType || !(returnType.flags & 134217728)) { + var typePredicate = getSignatureFromDeclaration(parent).typePredicate; + if (!typePredicate) { return; } var parameterName = node.parameterName; - if (parameterName.kind === 162) { + if (ts.isThisTypePredicate(typePredicate)) { getTypeFromThisTypeNode(parameterName); } else { - var typePredicate = returnType.predicate; if (typePredicate.parameterIndex >= 0) { if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); @@ -20554,10 +21233,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_14 = _a[_i].name; - if ((name_14.kind === 164 || - name_14.kind === 165) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, parameterName, typePredicate.parameterName)) { + var name_13 = _a[_i].name; + if (ts.isBindingPattern(name_13) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_13, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -20570,55 +21248,57 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 178: + case 149: + case 217: case 177: - case 148: - case 216: - case 176: - case 153: + case 154: + case 145: case 144: - case 143: - var parent_6 = node.parent; - if (node === parent_6.type) { - return parent_6; + var parent_7 = node.parent; + if (node === parent_7.type) { + return parent_7; } } } function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var name_15 = _a[_i].name; - if (name_15.kind === 69 && - name_15.text === predicateVariableName) { + var name_14 = _a[_i].name; + if (name_14.kind === 69 && + name_14.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_15.kind === 165 || - name_15.kind === 164) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_15, predicateVariableNode, predicateVariableName)) { + else if (name_14.kind === 166 || + name_14.kind === 165) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 150) { + if (node.kind === 151) { checkGrammarIndexSignature(node); } - else if (node.kind === 153 || node.kind === 216 || node.kind === 154 || - node.kind === 148 || node.kind === 145 || - node.kind === 149) { + else if (node.kind === 154 || node.kind === 217 || node.kind === 155 || + node.kind === 149 || node.kind === 146 || + node.kind === 150) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); - checkSourceElement(node.type); + if (node.type) { + checkSourceElement(node.type); + } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 149: + case 150: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 148: + case 149: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -20635,12 +21315,14 @@ var ts; checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } + else if (ts.isAsyncFunctionLike(node)) { + checkAsyncFunctionReturnType(node); + } } } - checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 218) { + if (node.kind === 219) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -20655,7 +21337,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 130: + case 131: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -20663,7 +21345,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 128: + case 129: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -20702,14 +21384,11 @@ var ts; if (!produceDiagnostics) { return; } - function isSuperCallExpression(n) { - return n.kind === 171 && n.expression.kind === 95; - } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { - if (isSuperCallExpression(n)) { + if (ts.isSuperCallExpression(n)) { return true; } else if (ts.isFunctionLike(n)) { @@ -20724,32 +21403,31 @@ var ts; if (n.kind === 97) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 176 && n.kind !== 216) { + else if (n.kind !== 177 && n.kind !== 217) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 142 && - !(n.flags & 64) && + return n.kind === 143 && + !(n.flags & 32) && !!n.initializer; } 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 classExtendsNull = classDeclarationExtendsNull(containingClassDecl); + var superCall = getSuperCallInConstructor(node); + if (superCall) { + if (classExtendsNull) { + error(superCall, 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 & (8 | 16 | 32); }); + ts.forEach(node.parameters, function (p) { return p.flags & (4 | 8 | 16); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - var superCallStatement; + var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 198 && isSuperCallExpression(statement.expression)) { + if (statement.kind === 199 && ts.isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -20760,12 +21438,9 @@ var ts; 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(superCallStatement.expression); - } } } - else if (baseConstructorType !== nullType) { + else if (!classExtendsNull) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -20775,9 +21450,9 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 146) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288)) { - if (node.flags & 1048576) { + if (node.kind === 147) { + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 32768)) { + if (node.flags & 65536) { if (compilerOptions.noImplicitReturns) { error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -20787,16 +21462,19 @@ var ts; } } } - if (node.name.kind === 137) { + if (node.name.kind === 138) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 146 ? 147 : 146; + var otherKind = node.kind === 147 ? 148 : 147; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 56) !== (otherAccessor.flags & 56))) { + if (((node.flags & 28) !== (otherAccessor.flags & 28))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } + if (((node.flags & 128) !== (otherAccessor.flags & 128))) { + error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + } var currentAccessorType = getAnnotatedAccessorType(node); var otherAccessorType = getAnnotatedAccessorType(otherAccessor); if (currentAccessorType && otherAccessorType) { @@ -20808,7 +21486,7 @@ var ts; } getTypeOfAccessors(getSymbolOfNode(node)); } - if (node.parent.kind !== 168) { + if (node.parent.kind !== 169) { checkSourceElement(node.body); } else { @@ -20875,49 +21553,18 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 16) && ts.isInAmbientContext(node); - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { - if (!produceDiagnostics) { - return; - } - var signature = getSignatureFromDeclaration(signatureDeclarationNode); - if (!signature.hasStringLiterals) { - return; - } - if (ts.nodeIsPresent(signatureDeclarationNode.body)) { - error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); - return; - } - var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 218) { - ts.Debug.assert(signatureDeclarationNode.kind === 148 || signatureDeclarationNode.kind === 149); - var signatureKind = signatureDeclarationNode.kind === 148 ? 0 : 1; - var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - var containingType = getDeclaredTypeOfSymbol(containingSymbol); - signaturesToCheck = getSignaturesOfType(containingType, signatureKind); - } - else { - signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); - } - for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { - var otherSignature = signaturesToCheck_1[_i]; - if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature, false)) { - return; - } - } - error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); + return (node.flags & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 218 && - n.parent.kind !== 217 && - n.parent.kind !== 189 && + if (n.parent.kind !== 219 && + n.parent.kind !== 218 && + n.parent.kind !== 190 && ts.isInAmbientContext(n)) { - if (!(flags & 4)) { - flags |= 2; + if (!(flags & 2)) { + flags |= 1; } - flags |= 4; + flags |= 2; } return flags & flagsToCheck; } @@ -20932,36 +21579,36 @@ var ts; function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; if (someButNotAllOverloadFlags !== 0) { - var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); + var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { - var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 2) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); + var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; + if (deviation & 1) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 4) { + else if (deviation & 2) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (16 | 32)) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); + else if (deviation & (8 | 16)) { + error(o.name || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } else if (deviation & 128) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); } } function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { if (someHaveQuestionToken !== allHaveQuestionToken) { - var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); ts.forEach(overloads, function (o) { - var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1; if (deviation) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); } }); } } - var flagsToCheck = 2 | 4 | 16 | 32 | 128; + var flagsToCheck = 1 | 2 | 8 | 16 | 128; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -20989,10 +21636,10 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 144 || node.kind === 143) && - (node.flags & 64) !== (subsequentNode.flags & 64); + var reportError = (node.kind === 145 || node.kind === 144) && + (node.flags & 32) !== (subsequentNode.flags & 32); if (reportError) { - var diagnostic = node.flags & 64 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = node.flags & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -21023,11 +21670,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 218 || node.parent.kind === 156 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 219 || node.parent.kind === 157 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 216 || node.kind === 144 || node.kind === 143 || node.kind === 145) { + if (node.kind === 217 || node.kind === 145 || node.kind === 144 || node.kind === 146) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -21078,13 +21725,11 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - if (!bodySignature.hasStringLiterals) { - for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { - var signature = signatures_3[_a]; - if (!signature.hasStringLiterals && !isImplementationCompatibleWithOverload(bodySignature, signature)) { - error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); - break; - } + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; + if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { + error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); + break; } } } @@ -21110,8 +21755,8 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 | 512); - if (effectiveDeclarationFlags & 2) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 512); + if (effectiveDeclarationFlags & 1) { if (effectiveDeclarationFlags & 512) { defaultExportedDeclarationSpaces |= declarationSpaces; } @@ -21140,20 +21785,20 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 218: + case 219: return 2097152; - case 221: + case 222: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 217: - case 220: + case 218: + case 221: return 2097152 | 1048576; - case 224: - var result = 0; + case 225: + var result_1 = 0; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); - return result; + ts.forEach(target.declarations, function (d) { result_1 |= getDeclarationSpaces(d); }); + return result_1; default: return 1048576; } @@ -21239,7 +21884,23 @@ var ts; } } } + function checkCorrectPromiseType(returnType, location) { + if (returnType === unknownType) { + return unknownType; + } + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType === emptyGenericType + || globalPromiseType === getTargetType(returnType)) { + return checkAwaitedType(returnType, location, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + error(location, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + return unknownType; + } function checkAsyncFunctionReturnType(node) { + if (languageVersion >= 2) { + var returnType = getTypeFromTypeNode(node.type); + return checkCorrectPromiseType(returnType, node.type); + } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType === emptyObjectType) { return unknownType; @@ -21280,22 +21941,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 217: + case 218: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 139: + case 140: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 142: + case 143: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 144: - case 146: + case 145: case 147: + case 148: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -21304,9 +21965,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 152) { + if (node && node.kind === 153) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 152 ? 793056 : 1536; + var meaning = root.parent.kind === 153 ? 793056 : 1536; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -21336,24 +21997,24 @@ var ts; return; } if (!compilerOptions.experimentalDecorators) { - error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 217: + case 218: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 144: - case 146: + case 145: case 147: + case 148: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 142: - case 139: + case 143: + case 140: checkTypeAnnotationAsExpression(node); break; } @@ -21366,13 +22027,14 @@ var ts; checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function checkFunctionOrMethodDeclaration(node) { checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 137) { + if (node.name && node.name.kind === 138) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -21404,7 +22066,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 195) { + if (node.kind === 196) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -21423,19 +22085,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 142 || - node.kind === 141 || + if (node.kind === 143 || + node.kind === 142 || + node.kind === 145 || node.kind === 144 || - node.kind === 143 || - node.kind === 146 || - node.kind === 147) { + node.kind === 147 || + node.kind === 148) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 139 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 140 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -21483,19 +22145,31 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 221 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 222 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 251 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 252 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } - function checkVarDeclaredNamesNotShadowed(node) { - if ((ts.getCombinedNodeFlags(node) & 24576) !== 0 || ts.isParameterDeclaration(node)) { + function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 214 && !node.initializer) { + if (node.kind === 222 && ts.getModuleInstanceState(node) !== 1) { + return; + } + var parent = getDeclarationContainer(node); + if (parent.kind === 252 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2097152) { + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); + } + } + function checkVarDeclaredNamesNotShadowed(node) { + if ((ts.getCombinedNodeFlags(node) & 3072) !== 0 || ts.isParameterDeclaration(node)) { + return; + } + if (node.kind === 215 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -21504,26 +22178,26 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 215); - var container = varDeclList.parent.kind === 196 && varDeclList.parent.parent + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 3072) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 216); + var container = varDeclList.parent.kind === 197 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 195 && ts.isFunctionLike(container.parent) || + (container.kind === 196 && ts.isFunctionLike(container.parent) || + container.kind === 223 || container.kind === 222 || - container.kind === 221 || - container.kind === 251); + container.kind === 252); if (!namesShareScope) { - var name_16 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_16, name_16); + 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); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 139) { + if (ts.getRootDeclaration(node).kind !== 140) { return; } var func = ts.getContainingFunction(node); @@ -21532,7 +22206,7 @@ var ts; if (n.kind === 69) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 139) { + if (referencedSymbol.valueDeclaration.kind === 140) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -21552,26 +22226,26 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 137) { + if (node.name.kind === 138) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 166) { - if (node.propertyName && node.propertyName.kind === 137) { + if (node.kind === 167) { + if (node.propertyName && node.propertyName.kind === 138) { checkComputedPropertyName(node.propertyName); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 139 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 140 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 203) { + if (node.initializer && node.parent.parent.kind !== 204) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -21580,7 +22254,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = getTypeOfVariableOrParameterOrProperty(symbol); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 203) { + if (node.initializer && node.parent.parent.kind !== 204) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -21594,14 +22268,15 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 142 && node.kind !== 141) { + if (node.kind !== 143 && node.kind !== 142) { checkExportsOnMergedDeclarations(node); - if (node.kind === 214 || node.kind === 166) { + if (node.kind === 215 || node.kind === 167) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function checkVariableDeclaration(node) { @@ -21617,7 +22292,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 168) { + if (node.modifiers && node.parent.kind === 169) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -21636,7 +22311,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 197) { + if (node.thenStatement.kind === 198) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -21653,12 +22328,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 215) { + if (node.initializer && node.initializer.kind === 216) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -21673,18 +22348,18 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 167 || varExpr.kind === 168) { + if (varExpr.kind === 168 || varExpr.kind === 169) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); if (iteratedType) { checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); } @@ -21694,7 +22369,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { 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); @@ -21704,14 +22379,14 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 167 || varExpr.kind === 168) { + if (varExpr.kind === 168 || varExpr.kind === 169) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); } } var rightType = checkExpression(node.expression); @@ -21871,8 +22546,8 @@ var ts; function checkBreakOrContinueStatement(node) { checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } - function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 146 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 147))); + function isGetAccessorWithAnnotatedSetAccessor(node) { + return !!(node.kind === 147 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 148))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -21890,15 +22565,15 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 147) { + if (func.kind === 148) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 145) { + else if (func.kind === 146) { if (!checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || returnType.flags & 134217728) { + else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -21915,7 +22590,7 @@ var ts; } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 8) { + if (node.flags & 33554432) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -21927,9 +22602,9 @@ var ts; var firstDefaultClause; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); - var expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, 258); + var expressionTypeIsStringLike = maybeTypeOfKind(expressionType, 258); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 245 && !hasDuplicateDefaultClause) { + if (clause.kind === 246 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21941,10 +22616,10 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 244) { + if (produceDiagnostics && clause.kind === 245) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); - var expressionTypeIsAssignableToCaseType = (expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, 258)) || + var expressionTypeIsAssignableToCaseType = (expressionTypeIsStringLike && maybeTypeOfKind(caseType, 258)) || isTypeAssignableTo(expressionType, caseType); if (!expressionTypeIsAssignableToCaseType) { checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); @@ -21960,7 +22635,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 210 && current.label.text === node.label.text) { + if (current.kind === 211 && 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; @@ -22027,7 +22702,7 @@ var ts; var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(member.flags & 64) && ts.hasDynamicName(member)) { + if (!(member.flags & 32) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); @@ -22054,7 +22729,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 137 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 138 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -22098,6 +22773,23 @@ var ts; } } } + function checkTypeParameterListsIdentical(node, symbol) { + if (symbol.declarations.length === 1) { + return; + } + var firstDecl; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 218 || declaration.kind === 219) { + if (!firstDecl) { + firstDecl = declaration; + } + else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + } + } + } + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -22120,6 +22812,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } checkTypeParameters(node.typeParameters); checkExportsOnMergedDeclarations(node); @@ -22127,12 +22820,14 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); + checkTypeParameterListsIdentical(node, symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { - var baseType = baseTypes[0]; + var baseType_1 = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); @@ -22143,15 +22838,15 @@ var ts; } } } - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); - if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } - checkKindsOfPropertyMemberOverrides(type, baseType); + checkKindsOfPropertyMemberOverrides(type, baseType_1); } } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); @@ -22181,6 +22876,18 @@ var ts; checkTypeForDuplicateIndexSignatures(node); } } + function checkBaseTypeAccessibility(type, node) { + var signatures = getSignaturesOfType(type, 1); + if (signatures.length) { + var declaration = signatures[0].declaration; + if (declaration && declaration.flags & 8) { + var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); + if (!isNodeWithinClass(node, typeClassDeclaration)) { + error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, node.expression.text); + } + } + } + } function getTargetSymbol(s) { return s.flags & 16777216 ? getSymbolLinks(s).target : s; } @@ -22202,7 +22909,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(derivedClassDecl.flags & 128))) { - if (derivedClassDecl.kind === 189) { + if (derivedClassDecl.kind === 190) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -22212,10 +22919,10 @@ var ts; } else { var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 16) || (derivedDeclarationFlags & 16)) { + if ((baseDeclarationFlags & 8) || (derivedDeclarationFlags & 8)) { continue; } - if ((baseDeclarationFlags & 64) !== (derivedDeclarationFlags & 64)) { + if ((baseDeclarationFlags & 32) !== (derivedDeclarationFlags & 32)) { continue; } if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { @@ -22246,7 +22953,7 @@ var ts; } } function isAccessor(kind) { - return kind === 146 || kind === 147; + return kind === 147 || kind === 148; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -22312,12 +23019,8 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 218); - if (symbol.declarations.length > 1) { - if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); - } - } + checkTypeParameterListsIdentical(node, symbol); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 219); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -22348,7 +23051,7 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 8192)) { + if (!(nodeLinks.flags & 16384)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; @@ -22381,7 +23084,7 @@ var ts; autoValue++; } } - nodeLinks.flags |= 8192; + nodeLinks.flags |= 16384; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { var reportError = true; @@ -22410,7 +23113,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 182: + case 183: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -22421,7 +23124,7 @@ var ts; case 50: return ~value_1; } return undefined; - case 184: + case 185: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -22446,22 +23149,22 @@ var ts; return undefined; case 8: return +e.text; - case 175: + case 176: return evalConstant(e.expression); case 69: + case 171: case 170: - case 169: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; - var propertyName; + var propertyName = void 0; if (e.kind === 69) { enumType_1 = currentType; propertyName = e.text; } else { - var expression; - if (e.kind === 170) { + var expression = void 0; + if (e.kind === 171) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -22478,7 +23181,7 @@ var ts; if (current.kind === 69) { break; } - else if (current.kind === 169) { + else if (current.kind === 170) { current = current.expression; } else { @@ -22519,6 +23222,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumIsConst = ts.isConst(node); @@ -22535,9 +23239,9 @@ var ts; } }); } - var seenEnumMissingInitialInitializer = false; + var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 220) { + if (declaration.kind !== 221) { return false; } var enumDeclaration = declaration; @@ -22546,11 +23250,11 @@ var ts; } var firstEnumMember = enumDeclaration.members[0]; if (!firstEnumMember.initializer) { - if (seenEnumMissingInitialInitializer) { + if (seenEnumMissingInitialInitializer_1) { error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); } else { - seenEnumMissingInitialInitializer = true; + seenEnumMissingInitialInitializer_1 = true; } } }); @@ -22560,8 +23264,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 217 || - (declaration.kind === 216 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 218 || + (declaration.kind === 217 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -22602,6 +23306,7 @@ var ts; } checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); if (symbol.flags & 512 @@ -22617,7 +23322,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, 217); + var mergedClass = ts.getDeclarationOfKind(symbol, 218); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -22655,40 +23360,40 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 196: + case 197: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 230: case 231: + case 232: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 224: + case 225: if (node.moduleReference.kind !== 9) { error(node.name, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); break; } - case 225: + case 226: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 166: - case 214: - var name_17 = node.name; - if (ts.isBindingPattern(name_17)) { - for (var _b = 0, _c = name_17.elements; _b < _c.length; _b++) { + case 167: + case 215: + var name_16 = node.name; + if (ts.isBindingPattern(name_16)) { + for (var _b = 0, _c = name_16.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 217: - case 220: - case 216: case 218: case 221: + case 217: case 219: + case 222: + case 220: var symbol = getSymbolOfNode(node); if (symbol) { var reportError = !(symbol.flags & 33554432); @@ -22709,10 +23414,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 136) { + if (node.kind === 137) { node = node.left; } - else if (node.kind === 169) { + else if (node.kind === 170) { node = node.expression; } else { @@ -22728,9 +23433,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 222 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 251 && !inAmbientExternalModule) { - error(moduleName, node.kind === 231 ? + var inAmbientExternalModule = node.parent.kind === 223 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 252 && !inAmbientExternalModule) { + error(moduleName, node.kind === 232 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -22751,7 +23456,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 233 ? + var message = node.kind === 234 ? 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)); @@ -22761,13 +23466,14 @@ var ts; function checkImportBinding(node) { checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); } function checkImportDeclaration(node) { if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -22777,7 +23483,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227) { + if (importClause.namedBindings.kind === 228) { checkImportBinding(importClause.namedBindings); } else { @@ -22794,7 +23500,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 2) { + if (node.flags & 1) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -22812,7 +23518,7 @@ var ts; } } else { - if (modulekind === 5 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } @@ -22822,27 +23528,27 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 222 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 251 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 223 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 252 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } else { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol && moduleSymbol.exports["export="]) { + if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } } } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 251 && node.parent.kind !== 222 && node.parent.kind !== 221) { + if (node.parent.kind !== 252 && node.parent.kind !== 223 && node.parent.kind !== 222) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -22851,7 +23557,7 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; var symbol = resolveName(exportedName, exportedName.text, 107455 | 793056 | 1536 | 8388608, undefined, undefined); - if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); } else { @@ -22863,12 +23569,12 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 251 ? node.parent : node.parent.parent; - if (container.kind === 221 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 252 ? node.parent : node.parent.parent; + if (container.kind === 222 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69) { @@ -22879,10 +23585,10 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === 5) { + if (modulekind === ts.ModuleKind.ES6) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (modulekind === 4) { + else if (modulekind === ts.ModuleKind.System) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } } @@ -22912,11 +23618,17 @@ var ts; continue; } var _a = exports_2[id], declarations = _a.declarations, flags = _a.flags; - if (!(flags & (1536 | 64 | 384)) && (flags & 524288 ? declarations.length - 1 : declarations.length) > 1) { - var exportedDeclarations = ts.filter(declarations, isNotOverload); - if (exportedDeclarations.length > 1) { - for (var _i = 0, exportedDeclarations_1 = exportedDeclarations; _i < exportedDeclarations_1.length; _i++) { - var declaration = exportedDeclarations_1[_i]; + if (flags & (1536 | 64 | 384)) { + continue; + } + var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); + if (flags & 524288 && exportedDeclarationsCount <= 2) { + continue; + } + if (exportedDeclarationsCount > 1) { + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } @@ -22925,7 +23637,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 216 || !!declaration.body; + return declaration.kind !== 217 || !!declaration.body; } } function checkSourceElement(node) { @@ -22935,118 +23647,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 221: - case 217: + case 222: case 218: - case 216: + case 219: + case 217: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 138: - return checkTypeParameter(node); case 139: + return checkTypeParameter(node); + case 140: return checkParameter(node); + case 143: case 142: - case 141: return checkPropertyDeclaration(node); - case 153: case 154: - case 148: + case 155: case 149: - return checkSignatureDeclaration(node); case 150: return checkSignatureDeclaration(node); - case 144: - case 143: - return checkMethodDeclaration(node); - case 145: - return checkConstructorDeclaration(node); - case 146: - case 147: - return checkAccessorDeclaration(node); - case 152: - return checkTypeReferenceNode(node); case 151: + return checkSignatureDeclaration(node); + case 145: + case 144: + return checkMethodDeclaration(node); + case 146: + return checkConstructorDeclaration(node); + case 147: + case 148: + return checkAccessorDeclaration(node); + case 153: + return checkTypeReferenceNode(node); + case 152: return checkTypePredicate(node); - case 155: - return checkTypeQuery(node); case 156: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 157: - return checkArrayType(node); + return checkTypeLiteral(node); case 158: - return checkTupleType(node); + return checkArrayType(node); case 159: + return checkTupleType(node); case 160: - return checkUnionOrIntersectionType(node); case 161: + return checkUnionOrIntersectionType(node); + case 162: return checkSourceElement(node.type); - case 216: - return checkFunctionDeclaration(node); - case 195: - case 222: - return checkBlock(node); - case 196: - return checkVariableStatement(node); - case 198: - return checkExpressionStatement(node); - case 199: - return checkIfStatement(node); - case 200: - return checkDoStatement(node); - case 201: - return checkWhileStatement(node); - case 202: - return checkForStatement(node); - case 203: - return checkForInStatement(node); - case 204: - return checkForOfStatement(node); - case 205: - case 206: - return checkBreakOrContinueStatement(node); - case 207: - return checkReturnStatement(node); - case 208: - return checkWithStatement(node); - case 209: - return checkSwitchStatement(node); - case 210: - return checkLabeledStatement(node); - case 211: - return checkThrowStatement(node); - case 212: - return checkTryStatement(node); - case 214: - return checkVariableDeclaration(node); - case 166: - return checkBindingElement(node); case 217: - return checkClassDeclaration(node); - case 218: - return checkInterfaceDeclaration(node); - case 219: - return checkTypeAliasDeclaration(node); - case 220: - return checkEnumDeclaration(node); - case 221: - return checkModuleDeclaration(node); - case 225: - return checkImportDeclaration(node); - case 224: - return checkImportEqualsDeclaration(node); - case 231: - return checkExportDeclaration(node); - case 230: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 196: + case 223: + return checkBlock(node); case 197: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 199: + return checkExpressionStatement(node); + case 200: + return checkIfStatement(node); + case 201: + return checkDoStatement(node); + case 202: + return checkWhileStatement(node); + case 203: + return checkForStatement(node); + case 204: + return checkForInStatement(node); + case 205: + return checkForOfStatement(node); + case 206: + case 207: + return checkBreakOrContinueStatement(node); + case 208: + return checkReturnStatement(node); + case 209: + return checkWithStatement(node); + case 210: + return checkSwitchStatement(node); + case 211: + return checkLabeledStatement(node); + case 212: + return checkThrowStatement(node); case 213: + return checkTryStatement(node); + case 215: + return checkVariableDeclaration(node); + case 167: + return checkBindingElement(node); + case 218: + return checkClassDeclaration(node); + case 219: + return checkInterfaceDeclaration(node); + case 220: + return checkTypeAliasDeclaration(node); + case 221: + return checkEnumDeclaration(node); + case 222: + return checkModuleDeclaration(node); + case 226: + return checkImportDeclaration(node); + case 225: + return checkImportEqualsDeclaration(node); + case 232: + return checkExportDeclaration(node); + case 231: + return checkExportAssignment(node); + case 198: checkGrammarStatementInAmbientContext(node); return; - case 234: + case 214: + checkGrammarStatementInAmbientContext(node); + return; + case 235: return checkMissingDeclaration(node); } } @@ -23059,17 +23771,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 176: case 177: + case 178: + case 145: case 144: - case 143: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 146: case 147: + case 148: checkAccessorDeferred(node); break; - case 189: + case 190: checkClassExpressionDeferred(node); break; } @@ -23134,7 +23846,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 208 && node.parent.statement === node) { + if (node.parent.kind === 209 && node.parent.statement === node) { return true; } node = node.parent; @@ -23156,28 +23868,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 251: + case 252: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 221: + case 222: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 220: + case 221: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 189: + case 190: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 217: case 218: - if (!(memberFlags & 64)) { + case 219: + if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 176: + case 177: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -23216,36 +23928,47 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 138: - case 217: + case 139: case 218: case 219: case 220: + case 221: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 136) { + while (node.parent && node.parent.kind === 137) { node = node.parent; } - return node.parent && node.parent.kind === 152; + return node.parent && node.parent.kind === 153; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 169) { + while (node.parent && node.parent.kind === 170) { node = node.parent; } - return node.parent && node.parent.kind === 191; + return node.parent && node.parent.kind === 192; + } + function isNodeWithinClass(node, classDeclaration) { + while (true) { + node = ts.getContainingClass(node); + if (!node) { + return false; + } + if (node === classDeclaration) { + return true; + } + } } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 136) { + while (nodeOnRightSide.parent.kind === 137) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224) { + if (nodeOnRightSide.parent.kind === 225) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 230) { + if (nodeOnRightSide.parent.kind === 231) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -23257,10 +23980,22 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 230) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 170) { + var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case 1: + case 3: + return getSymbolOfNode(entityName.parent); + case 4: + case 2: + return getSymbolOfNode(entityName.parent.parent); + default: + } + } + if (entityName.parent.kind === 231) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 169) { + if (entityName.kind !== 170) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -23270,7 +24005,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 191) { + if (entityName.parent.kind === 192) { meaning = 793056; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -23282,10 +24017,10 @@ var ts; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 238) || - (entityName.parent.kind === 237) || - (entityName.parent.kind === 240)) { - return getJsxElementTagSymbol(entityName.parent); + else if ((entityName.parent.kind === 239) || + (entityName.parent.kind === 238) || + (entityName.parent.kind === 241)) { + return getJsxTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { @@ -23295,14 +24030,14 @@ var ts; var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 169) { + else if (entityName.kind === 170) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 136) { + else if (entityName.kind === 137) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -23311,14 +24046,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 152 ? 793056 : 1536; + var meaning = entityName.parent.kind === 153 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 241) { + else if (entityName.parent.kind === 242) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 151) { + if (entityName.parent.kind === 152) { return resolveEntityName(entityName, 1); } return undefined; @@ -23332,12 +24067,12 @@ var ts; } if (node.kind === 69) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 230 + return node.parent.kind === 231 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 166 && - node.parent.parent.kind === 164 && + else if (node.parent.kind === 167 && + node.parent.parent.kind === 165 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -23348,30 +24083,30 @@ var ts; } switch (node.kind) { case 69: - case 169: - case 136: + case 170: + case 137: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97: case 95: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 162: + case 163: return getTypeFromTypeNode(node).symbol; case 121: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 145) { + if (constructorDeclaration && constructorDeclaration.kind === 146) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 225 || node.parent.kind === 231) && + ((node.parent.kind === 226 || node.parent.kind === 232) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 170 && node.parent.argumentExpression === node) { + if (node.parent.kind === 171 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -23385,7 +24120,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 249) { + if (location && location.kind === 250) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -23442,7 +24177,7 @@ var ts; } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 64 + return node.flags & 32 ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -23460,15 +24195,15 @@ var ts; } function getRootSymbols(symbol) { if (symbol.flags & 268435456) { - var symbols = []; - var name_18 = symbol.name; + var symbols_3 = []; + var name_17 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_18); + var symbol = getPropertyOfType(t, name_17); if (symbol) { - symbols.push(symbol); + symbols_3.push(symbol); } }); - return symbols; + return symbols_3; } else if (symbol.flags & 67108864) { var target = getSymbolLinks(symbol).target; @@ -23486,7 +24221,7 @@ var ts; if (!moduleSymbol) { return true; } - var hasExportAssignment = getExportAssignmentSymbol(moduleSymbol) !== undefined; + var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol); moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); var symbolLinks = getSymbolLinks(moduleSymbol); if (symbolLinks.exportsSomeValue === undefined) { @@ -23512,11 +24247,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 251) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 252) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 221 || n.kind === 220) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 222 || n.kind === 221) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -23527,54 +24262,56 @@ var ts; var symbol = getReferencedValueSymbol(node); return symbol && symbol.flags & 8388608 ? getDeclarationOfAliasSymbol(symbol) : undefined; } - function isStatementWithLocals(node) { - switch (node.kind) { - case 195: - case 223: - case 202: - case 203: - case 204: - return true; - } - return false; - } - function isNestedRedeclarationSymbol(symbol) { + function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418) { var links = getSymbolLinks(symbol); - if (links.isNestedRedeclaration === undefined) { + if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455, undefined, undefined); + if (ts.isStatementWithLocals(container)) { + var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); + if (!!resolveName(container.parent, symbol.name, 107455, undefined, undefined)) { + links.isDeclarationWithCollidingName = true; + } + else if (nodeLinks_1.flags & 131072) { + var isDeclaredInLoop = nodeLinks_1.flags & 262144; + var inLoopInitializer = ts.isIterationStatement(container, false); + var inLoopBodyBlock = container.kind === 196 && ts.isIterationStatement(container.parent, false); + links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); + } + else { + links.isDeclarationWithCollidingName = false; + } + } } - return links.isNestedRedeclaration; + return links.isDeclarationWithCollidingName; } return false; } - function getReferencedNestedRedeclaration(node) { + function getReferencedDeclarationWithCollidingName(node) { var symbol = getReferencedValueSymbol(node); - return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + return symbol && isSymbolOfDeclarationWithCollidingName(symbol) ? symbol.valueDeclaration : undefined; } - function isNestedRedeclaration(node) { - return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + function isDeclarationWithCollidingName(node) { + return isSymbolOfDeclarationWithCollidingName(getSymbolOfNode(node)); } function isValueAliasDeclaration(node) { switch (node.kind) { - case 224: - case 226: + case 225: case 227: - case 229: - case 233: + case 228: + case 230: + case 234: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 231: + case 232: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 230: + case 231: return node.expression && node.expression.kind === 69 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 251 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 252 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -23622,7 +24359,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 250) { + if (node.kind === 251) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -23653,22 +24390,22 @@ var ts; else if (type.flags & 1) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (allConstituentTypesHaveKind(type, 16)) { + else if (isTypeOfKind(type, 16)) { return ts.TypeReferenceSerializationKind.VoidType; } - else if (allConstituentTypesHaveKind(type, 8)) { + else if (isTypeOfKind(type, 8)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (allConstituentTypesHaveKind(type, 132)) { + else if (isTypeOfKind(type, 132)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (allConstituentTypesHaveKind(type, 258)) { + else if (isTypeOfKind(type, 258)) { return ts.TypeReferenceSerializationKind.StringLikeType; } - else if (allConstituentTypesHaveKind(type, 8192)) { + else if (isTypeOfKind(type, 8192)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 16777216)) { + else if (isTypeOfKind(type, 16777216)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -23712,8 +24449,8 @@ var ts; return { getReferencedExportContainer: getReferencedExportContainer, getReferencedImportDeclaration: getReferencedImportDeclaration, - getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, - isNestedRedeclaration: isNestedRedeclaration, + getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName, + isDeclarationWithCollidingName: isDeclarationWithCollidingName, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -23742,7 +24479,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 251); + return ts.getDeclarationOfKind(moduleSymbol, 252); } function initializeTypeChecker() { ts.forEach(host.getSourceFiles(), function (file) { @@ -23753,7 +24490,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } - if (file.moduleAugmentations) { + if (file.moduleAugmentations.length) { (augmentations || (augmentations = [])).push(file.moduleAugmentations); } }); @@ -23807,6 +24544,9 @@ var ts; globalIterableIteratorType = emptyGenericType; } anyArrayType = createArrayType(anyType); + var symbol = getGlobalSymbol("ReadonlyArray", 793056, undefined); + globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); + anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); @@ -23830,14 +24570,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 144 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 145 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 146 || node.kind === 147) { + else if (node.kind === 147 || node.kind === 148) { 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); @@ -23847,38 +24587,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 146: case 147: - case 145: - case 142: - case 141: - case 144: + case 148: + case 146: case 143: - case 150: - case 221: + case 142: + case 145: + case 144: + case 151: + case 222: + case 226: case 225: - case 224: + case 232: case 231: - case 230: - case 139: - break; - case 216: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && - node.parent.kind !== 222 && node.parent.kind !== 251) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 140: break; case 217: - case 218: - case 196: - case 219: - if (node.modifiers && node.parent.kind !== 222 && node.parent.kind !== 251) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118) && + node.parent.kind !== 223 && node.parent.kind !== 252) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 218: + case 219: + case 197: case 220: + if (node.modifiers && node.parent.kind !== 223 && node.parent.kind !== 252) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 221: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74) && - node.parent.kind !== 222 && node.parent.kind !== 251) { + node.parent.kind !== 223 && node.parent.kind !== 252) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23888,42 +24628,48 @@ var ts; if (!node.modifiers) { return; } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync, lastReadonly; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; + if (modifier.kind !== 127) { + if (node.kind === 142 || node.kind === 144) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); + } + if (node.kind === 151) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); + } + } switch (modifier.kind) { case 74: - if (node.kind !== 220 && node.parent.kind === 217) { + if (node.kind !== 221 && node.parent.kind === 218) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); } break; case 112: case 111: case 110: - var text = void 0; - if (modifier.kind === 112) { - text = "public"; - } - else if (modifier.kind === 111) { - text = "protected"; + var text = visibilityToString(ts.modifierToFlag(modifier.kind)); + if (modifier.kind === 111) { lastProtected = modifier; } - else { - text = "private"; + else if (modifier.kind === 110) { lastPrivate = modifier; } - if (flags & 56) { + if (flags & 28) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 64) { + else if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } + else if (flags & 64) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); + } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 222 || node.parent.kind === 251) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + else if (node.parent.kind === 223 || node.parent.kind === 252) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { if (modifier.kind === 110) { @@ -23936,29 +24682,42 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113: - if (flags & 64) { + if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } + else if (flags & 64) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); + } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 222 || node.parent.kind === 251) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + else if (node.parent.kind === 223 || node.parent.kind === 252) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 139) { + else if (node.kind === 140) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 64; + flags |= 32; lastStatic = modifier; break; + case 127: + if (flags & 64) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); + } + else if (node.kind !== 143 && node.kind !== 142 && node.kind !== 151) { + return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); + } + flags |= 64; + lastReadonly = modifier; + break; case 82: - if (flags & 2) { + if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 4) { + else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } else if (flags & 128) { @@ -23967,48 +24726,51 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 217) { + else if (node.parent.kind === 218) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 139) { + else if (node.kind === 140) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 2; + flags |= 1; break; case 122: - if (flags & 4) { + if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 217) { + else if (node.parent.kind === 218) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 139) { + else if (node.kind === 140) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 222) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 223) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 4; + flags |= 2; lastDeclare = modifier; break; case 115: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 217) { - if (node.kind !== 144) { - return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + if (node.kind !== 218) { + if (node.kind !== 145 && + node.kind !== 143 && + node.kind !== 147 && + node.kind !== 148) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 217 && node.parent.flags & 128)) { + if (!(node.parent.kind === 218 && node.parent.flags & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 64) { + if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 16) { + if (flags & 8) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } @@ -24018,10 +24780,10 @@ var ts; if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 4 || ts.isInAmbientContext(node.parent)) { + 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 === 139) { + else if (node.kind === 140) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -24029,28 +24791,25 @@ var ts; break; } } - if (node.kind === 145) { - if (flags & 64) { + if (node.kind === 146) { + if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 32) { - return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & 16) { - return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } else if (flags & 256) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } + else if (flags & 64) { + return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly"); + } return; } - else if ((node.kind === 225 || node.kind === 224) && flags & 4) { + else if ((node.kind === 226 || node.kind === 225) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 139 && (flags & 56) && ts.isBindingPattern(node.name)) { + else if (node.kind === 140 && (flags & 28) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 256) { @@ -24062,10 +24821,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 144: - case 216: - case 176: + case 145: + case 217: case 177: + case 178: if (!node.asteriskToken) { return false; } @@ -24130,7 +24889,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 177) { + if (node.kind === 178) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -24153,7 +24912,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 1022) { + if (parameter.flags & 959) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -24165,20 +24924,15 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 130 && parameter.type.kind !== 128) { + if (parameter.type.kind !== 131 && parameter.type.kind !== 129) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); } } - function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 1022) { - grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } function checkGrammarIndexSignature(node) { - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node); } function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { if (typeArguments && typeArguments.length === 0) { @@ -24197,7 +24951,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { var arg = args_1[_i]; - if (arg.kind === 190) { + if (arg.kind === 191) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -24268,19 +25022,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 137) { + if (node.kind !== 138) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 184 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 185 && 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 === 216 || - node.kind === 176 || - node.kind === 144); + ts.Debug.assert(node.kind === 217 || + node.kind === 177 || + node.kind === 145); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -24301,88 +25055,88 @@ var ts; var seen = {}; var Property = 1; var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; + var SetAccessor = 4; + var GetOrSetAccessor = GetAccessor | SetAccessor; var _loop_1 = function(prop) { - var name_19 = prop.name; - if (prop.kind === 190 || - name_19.kind === 137) { - checkGrammarComputedPropertyName(name_19); + var name_18 = prop.name; + if (prop.kind === 191 || + name_18.kind === 138) { + checkGrammarComputedPropertyName(name_18); return "continue"; } - if (prop.kind === 249 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 250 && !inDestructuring && prop.objectAssignmentInitializer) { return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) }; } ts.forEach(prop.modifiers, function (mod) { - if (mod.kind !== 118 || prop.kind !== 144) { + if (mod.kind !== 118 || prop.kind !== 145) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } }); var currentKind = void 0; - if (prop.kind === 248 || prop.kind === 249) { + if (prop.kind === 249 || prop.kind === 250) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_19.kind === 8) { - checkGrammarNumericLiteral(name_19); + if (name_18.kind === 8) { + checkGrammarNumericLiteral(name_18); } currentKind = Property; } - else if (prop.kind === 144) { + else if (prop.kind === 145) { currentKind = Property; } - else if (prop.kind === 146) { + else if (prop.kind === 147) { currentKind = GetAccessor; } - else if (prop.kind === 147) { - currentKind = SetAccesor; + else if (prop.kind === 148) { + currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_19.text)) { - seen[name_19.text] = currentKind; + if (!ts.hasProperty(seen, name_18.text)) { + seen[name_18.text] = currentKind; } else { - var existingKind = seen[name_19.text]; + var existingKind = seen[name_18.text]; if (currentKind === Property && existingKind === Property) { return "continue"; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_19.text] = currentKind | existingKind; + seen[name_18.text] = currentKind | existingKind; } else { - return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; + return { value: grammarErrorOnNode(name_18, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; } } else { - return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; + return { value: grammarErrorOnNode(name_18, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; } } }; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var state_1 = _loop_1(prop); - if (typeof state_1 === "object") return state_1.value - if (state_1 === "continue") continue; + var state_2 = _loop_1(prop); + if (typeof state_2 === "object") return state_2.value; + if (state_2 === "continue") continue; } } function checkGrammarJsxElement(node) { var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 242) { + if (attr.kind === 243) { continue; } var jsxAttr = attr; - var name_20 = jsxAttr.name; - if (!ts.hasProperty(seen, name_20.text)) { - seen[name_20.text] = true; + var name_19 = jsxAttr.name; + if (!ts.hasProperty(seen, name_19.text)) { + seen[name_19.text] = true; } else { - return grammarErrorOnNode(name_20, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_19, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 243 && !initializer.expression) { + if (initializer && initializer.kind === 244 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -24391,7 +25145,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 215) { + if (forInOrOfStatement.initializer.kind === 216) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -24399,20 +25153,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 203 + var diagnostic = forInOrOfStatement.kind === 204 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 203 + var diagnostic = forInOrOfStatement.kind === 204 ? 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 === 203 + var diagnostic = forInOrOfStatement.kind === 204 ? 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); @@ -24429,16 +25183,16 @@ var ts; else if (ts.isInAmbientContext(accessor)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); } - else if (accessor.body === undefined) { + else if (accessor.body === undefined && !(accessor.flags & 128)) { return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 146 && accessor.parameters.length) { + else if (kind === 147 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 147) { + else if (kind === 148) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -24450,7 +25204,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 1022) { + else if (parameter.flags & 959) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -24473,7 +25227,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 168) { + if (node.parent.kind === 169) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -24492,10 +25246,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 219) { 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 === 156) { + else if (node.parent.kind === 157) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -24506,9 +25260,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 210: + case 211: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 205 + var isMisplacedContinueLabel = node.kind === 206 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -24516,8 +25270,8 @@ var ts; return false; } break; - case 209: - if (node.kind === 206 && !node.label) { + case 210: + if (node.kind === 207 && !node.label) { return false; } break; @@ -24530,13 +25284,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 206 + var message = node.kind === 207 ? 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 === 206 + var message = node.kind === 207 ? 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); @@ -24548,7 +25302,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 === 165 || node.name.kind === 164) { + if (node.name.kind === 166 || node.name.kind === 165) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -24557,7 +25311,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 203 && node.parent.parent.kind !== 204) { + if (node.parent.parent.kind !== 204 && node.parent.parent.kind !== 205) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -24586,7 +25340,7 @@ var ts; var elements = name.elements; for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { var element = elements_2[_i]; - if (element.kind !== 190) { + if (element.kind !== 191) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -24603,15 +25357,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 199: case 200: case 201: - case 208: case 202: + case 209: case 203: case 204: + case 205: return false; - case 210: + case 211: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -24667,7 +25421,7 @@ var ts; return true; } } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 219) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -24675,7 +25429,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 156) { + else if (node.parent.kind === 157) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -24688,14 +25442,14 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 218 || - node.kind === 219 || + if (node.kind === 219 || + node.kind === 220 || + node.kind === 226 || node.kind === 225 || - node.kind === 224 || + node.kind === 232 || node.kind === 231 || - node.kind === 230 || - (node.flags & 4) || - (node.flags & (2 | 512))) { + (node.flags & 2) || + (node.flags & (1 | 512))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -24703,7 +25457,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 === 196) { + if (ts.isDeclaration(decl) || decl.kind === 197) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -24722,7 +25476,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 === 195 || node.parent.kind === 222 || node.parent.kind === 251) { + if (node.parent.kind === 196 || node.parent.kind === 223 || node.parent.kind === 252) { 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); @@ -24733,7 +25487,7 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 32768 && languageVersion >= 1) { + if (node.isOctalLiteral && languageVersion >= 1) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -24752,6 +25506,13 @@ var ts; var ts; (function (ts) { var nullSourceMapWriter; + var defaultLastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; function getNullSourceMapWriter() { if (nullSourceMapWriter === undefined) { nullSourceMapWriter = { @@ -24800,13 +25561,7 @@ var ts; currentSourceFile = undefined; sourceMapSourceIndex = -1; lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; + lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; lastEncodedNameIndex = 0; sourceMapData = { sourceMapFilePath: sourceMapFilePath, @@ -24859,7 +25614,7 @@ var ts; sourceMapData.sourceMapDecodedMappings.pop(); lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - undefined; + defaultLastEncodedSourceMapSpan; var sourceMapMappings = sourceMapData.sourceMapMappings; var lenthToSet = sourceMapMappings.length - 1; for (; lenthToSet >= 0; lenthToSet--) { @@ -25032,7 +25787,8 @@ var ts; var increaseIndent; var decreaseIndent; var writeTextOfNode; - var writer = createAndSetNewTextWriterWithSymbolWriter(); + var writer; + createAndSetNewTextWriterWithSymbolWriter(); var enclosingDeclaration; var resultHasExternalModuleIndicator; var currentText; @@ -25084,7 +25840,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 225); + ts.Debug.assert(aliasEmitInfo.node.kind === 226); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -25137,7 +25893,6 @@ var ts; writer.writeParameter = writer.write; writer.writeSymbol = writer.write; setWriter(writer); - return writer; } function setWriter(newWriter) { writer = newWriter; @@ -25151,10 +25906,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 214) { + if (declaration.kind === 215) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 228 || declaration.kind === 229 || declaration.kind === 226) { + else if (declaration.kind === 229 || declaration.kind === 230 || declaration.kind === 227) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -25165,7 +25920,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 225) { + if (moduleElementEmitInfo.node.kind === 226) { moduleElementEmitInfo.isVisible = true; } else { @@ -25173,12 +25928,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 221) { + if (nodeToCheck.kind === 222) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 221) { + if (nodeToCheck.kind === 222) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -25188,21 +25943,21 @@ var ts; }); setWriter(oldWriter); } - function handleSymbolAccessibilityError(symbolAccesibilityResult) { - if (symbolAccesibilityResult.accessibility === 0) { - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + function handleSymbolAccessibilityError(symbolAccessibilityResult) { + if (symbolAccessibilityResult.accessibility === 0) { + if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccessibilityResult.aliasesToMakeVisible); } } else { reportedDeclarationError = true; - var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccessibilityResult); if (errorInfo) { if (errorInfo.typeName) { - emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNodeFromSourceText(currentText, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNodeFromSourceText(currentText, errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } else { - emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } } } @@ -25276,40 +26031,40 @@ var ts; function emitType(type) { switch (type.kind) { case 117: - case 130: - case 128: - case 120: case 131: + case 129: + case 120: + case 132: case 103: - case 162: case 163: + case 164: return writeTextOfNode(currentText, type); - case 191: + case 192: return emitExpressionWithTypeArguments(type); - case 152: - return emitTypeReference(type); - case 155: - return emitTypeQuery(type); - case 157: - return emitArrayType(type); - case 158: - return emitTupleType(type); - case 159: - return emitUnionType(type); - case 160: - return emitIntersectionType(type); - case 161: - return emitParenType(type); case 153: - case 154: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 156: + return emitTypeQuery(type); + case 158: + return emitArrayType(type); + case 159: + return emitTupleType(type); + case 160: + return emitUnionType(type); + case 161: + return emitIntersectionType(type); + case 162: + return emitParenType(type); + case 154: + case 155: + return emitSignatureDeclarationWithJsDocComments(type); + case 157: return emitTypeLiteral(type); case 69: return emitEntityName(type); - case 136: + case 137: return emitEntityName(type); - case 151: + case 152: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -25317,21 +26072,21 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 136 ? entityName.left : entityName.expression; - var right = entityName.kind === 136 ? entityName.right : entityName.name; + var left = entityName.kind === 137 ? entityName.left : entityName.expression; + var right = entityName.kind === 137 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 224 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 225 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 169); + ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 170); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -25405,9 +26160,9 @@ var ts; var count = 0; while (true) { count++; - var name_21 = baseName + "_" + count; - if (!ts.hasProperty(currentIdentifiers, name_21)) { - return name_21; + var name_20 = baseName + "_" + count; + if (!ts.hasProperty(currentIdentifiers, name_20)) { + return name_20; } } } @@ -25448,10 +26203,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 224 || - (node.parent.kind === 251 && isCurrentFileExternalModule)) { - var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 251) { + else if (node.kind === 225 || + (node.parent.kind === 252 && isCurrentFileExternalModule)) { + var isVisible = void 0; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 252) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -25460,7 +26215,7 @@ var ts; }); } else { - if (node.kind === 225) { + if (node.kind === 226) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -25478,58 +26233,61 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 216: - return writeFunctionDeclaration(node); - case 196: - return writeVariableStatement(node); - case 218: - return writeInterfaceDeclaration(node); case 217: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 197: + return writeVariableStatement(node); case 219: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 218: + return writeClassDeclaration(node); case 220: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 221: + return writeEnumDeclaration(node); + case 222: return writeModuleDeclaration(node); - case 224: - return writeImportEqualsDeclaration(node); case 225: + return writeImportEqualsDeclaration(node); + case 226: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 251) { - if (node.flags & 2) { + if (node.parent.kind === 252) { + if (node.flags & 1) { write("export "); } if (node.flags & 512) { write("default "); } - else if (node.kind !== 218 && !noDeclare) { + else if (node.kind !== 219 && !noDeclare) { write("declare "); } } } - function emitClassMemberDeclarationFlags(node) { - if (node.flags & 16) { + function emitClassMemberDeclarationFlags(flags) { + if (flags & 8) { write("private "); } - else if (node.flags & 32) { + else if (flags & 16) { write("protected "); } - if (node.flags & 64) { + if (flags & 32) { write("static "); } - if (node.flags & 128) { + if (flags & 64) { + write("readonly "); + } + if (flags & 128) { write("abstract "); } } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); - if (node.flags & 2) { + if (node.flags & 1) { write("export "); } write("import "); @@ -25545,7 +26303,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult) { + function getImportEntityNameVisibilityError(symbolAccessibilityResult) { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -25555,7 +26313,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 227) { + if (namedBindings.kind === 228) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -25564,11 +26322,8 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 2)) { - return; - } emitJsDocComments(node); - if (node.flags & 2) { + if (node.flags & 1) { write("export "); } write("import "); @@ -25581,7 +26336,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 227) { + if (node.importClause.namedBindings.kind === 228) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -25598,13 +26353,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 221; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 222; var moduleSpecifier; - if (parent.kind === 224) { + if (parent.kind === 225) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 221) { + else if (parent.kind === 222) { moduleSpecifier = parent.name; } else { @@ -25659,7 +26414,7 @@ var ts; write("global "); } else { - if (node.flags & 65536) { + if (node.flags & 4096) { write("namespace "); } else { @@ -25672,7 +26427,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body.kind !== 222) { + while (node.body.kind !== 223) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -25701,7 +26456,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -25737,7 +26492,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 144 && (node.parent.flags & 16); + return node.parent.kind === 145 && (node.parent.flags & 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -25747,49 +26502,49 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 153 || - node.parent.kind === 154 || - (node.parent.parent && node.parent.parent.kind === 156)) { - ts.Debug.assert(node.parent.kind === 144 || - node.parent.kind === 143 || - node.parent.kind === 153 || + if (node.parent.kind === 154 || + node.parent.kind === 155 || + (node.parent.parent && node.parent.parent.kind === 157)) { + ts.Debug.assert(node.parent.kind === 145 || + node.parent.kind === 144 || node.parent.kind === 154 || - node.parent.kind === 148 || - node.parent.kind === 149); + node.parent.kind === 155 || + node.parent.kind === 149 || + node.parent.kind === 150); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 217: + case 218: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 218: + case 219: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 149: + case 150: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 148: + case 149: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 145: case 144: - case 143: - if (node.parent.flags & 64) { + if (node.parent.flags & 32) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 217) { + else if (node.parent.parent.kind === 218) { 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 216: + case 217: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -25820,9 +26575,9 @@ var ts; else if (!isImplementsList && node.expression.kind === 93) { write("null"); } - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + function getHeritageClauseVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 217) { + if (node.parent.parent.kind === 218) { 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; @@ -25842,7 +26597,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 56) { + if (param.flags & 28) { emitPropertyDeclaration(param); } }); @@ -25896,61 +26651,61 @@ var ts; return; } emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags); emitVariableDeclaration(node); write(";"); writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 214 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 215 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 142 || node.kind === 141) && ts.hasQuestionToken(node)) { + if ((node.kind === 143 || node.kind === 142) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 142 || node.kind === 141) && node.parent.kind === 156) { + if ((node.kind === 143 || node.kind === 142) && node.parent.kind === 157) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 16)) { + else if (!(node.flags & 8)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 214) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { + if (node.kind === 215) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 142 || node.kind === 141) { - if (node.flags & 64) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + else if (node.kind === 143 || node.kind === 142) { + if (node.flags & 32) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 217) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + else if (node.parent.kind === 218) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; } } } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, @@ -25961,15 +26716,15 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 190) { + if (element.kind !== 191) { elements.push(element); } } emitCommaList(elements, emitBindingElement); } function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getBindingElementTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: bindingElement, @@ -26021,13 +26776,13 @@ var ts; if (node === accessors.firstAccessor) { emitJsDocComments(accessors.getAccessor); emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags | (accessors.setAccessor ? 0 : 64)); writeTextOfNode(currentText, node.name); - if (!(node.flags & 16)) { + if (!(node.flags & 8)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 146 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 147 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -26040,23 +26795,23 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 146 + return accessor.kind === 147 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type : undefined; } } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 147) { - if (accessorWithTypeAnnotation.parent.flags & 64) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + if (accessorWithTypeAnnotation.kind === 148) { + if (accessorWithTypeAnnotation.parent.flags & 32) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; } @@ -26067,16 +26822,16 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 64) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + if (accessorWithTypeAnnotation.flags & 32) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; @@ -26095,17 +26850,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 216) { + if (node.kind === 217) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 144) { - emitClassMemberDeclarationFlags(node); + else if (node.kind === 145 || node.kind === 146) { + emitClassMemberDeclarationFlags(node.flags); } - if (node.kind === 216) { + if (node.kind === 217) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 145) { + else if (node.kind === 146) { write("constructor"); } else { @@ -26124,31 +26879,32 @@ var ts; function emitSignatureDeclaration(node) { var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; - if (node.kind === 149 || node.kind === 154) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 150) { + if (node.kind === 151) { + emitClassMemberDeclarationFlags(node.flags); write("["); } else { + if (node.kind === 150 || node.kind === 155) { + write("new "); + } + emitTypeParameters(node.typeParameters); write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 150) { + if (node.kind === 151) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 153 || node.kind === 154; - if (isFunctionTypeOrConstructorType || node.parent.kind === 156) { + var isFunctionTypeOrConstructorType = node.kind === 154 || node.kind === 155; + if (isFunctionTypeOrConstructorType || node.parent.kind === 157) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 145 && !(node.flags & 16)) { + else if (node.kind !== 146 && !(node.flags & 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -26156,49 +26912,49 @@ var ts; write(";"); writeLine(); } - function getReturnTypeVisibilityError(symbolAccesibilityResult) { + function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 149: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + case 150: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 148: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + case 149: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 150: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + case 151: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 145: case 144: - case 143: - if (node.flags & 64) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + if (node.flags & 32) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : 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 === 217) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + else if (node.parent.kind === 218) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 216: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + case 217: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -26228,62 +26984,62 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 153 || - node.parent.kind === 154 || - node.parent.parent.kind === 156) { + if (node.parent.kind === 154 || + node.parent.kind === 155 || + node.parent.parent.kind === 157) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 16)) { + else if (!(node.parent.flags & 8)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, typeName: node.name } : undefined; } - function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 145: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + case 146: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 149: - return symbolAccesibilityResult.errorModuleName ? + case 150: + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 148: - return symbolAccesibilityResult.errorModuleName ? + case 149: + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 145: case 144: - case 143: - if (node.parent.flags & 64) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + if (node.parent.flags & 32) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 217) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + else if (node.parent.parent.kind === 218) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? 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 216: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 ? + case 217: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; @@ -26292,12 +27048,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 164) { + if (bindingPattern.kind === 165) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 165) { + else if (bindingPattern.kind === 166) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -26308,10 +27064,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 190) { + if (bindingElement.kind === 191) { write(" "); } - else if (bindingElement.kind === 166) { + else if (bindingElement.kind === 167) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -26333,39 +27089,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 216: - case 221: - case 224: - case 218: case 217: - case 219: - case 220: - return emitModuleElement(node, isModuleElementVisible(node)); - case 196: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 222: case 225: + case 219: + case 218: + case 220: + case 221: + return emitModuleElement(node, isModuleElementVisible(node)); + case 197: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 226: return emitModuleElement(node, !node.importClause); - case 231: + case 232: return emitExportDeclaration(node); + case 146: case 145: case 144: - case 143: return writeFunctionDeclaration(node); - case 149: - case 148: case 150: + case 149: + case 151: return emitSignatureDeclarationWithJsDocComments(node); - case 146: case 147: + case 148: return emitAccessorDeclaration(node); + case 143: case 142: - case 141: return emitPropertyDeclaration(node); - case 250: - return emitEnumMemberDeclaration(node); - case 230: - return emitExportAssignment(node); case 251: + return emitEnumMemberDeclaration(node); + case 231: + return emitExportAssignment(node); + case 252: return emitSourceFile(node); } } @@ -26692,7 +27448,7 @@ var ts; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new P(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.call(thisArg, _arguments)).next());\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -26761,9 +27517,11 @@ var ts; var isEs6Module; var isCurrentFileExternalModule; var exportFunctionForFile; + var contextObjectForFile; var generatedNameSet; var nodeToGeneratedName; var computedPropertyNamesToGeneratedNames; + var decoratedClassAliases; var convertedLoopState; var extendsEmitted; var decorateEmitted; @@ -26782,19 +27540,19 @@ var ts; var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; var setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer) { }; var moduleEmitDelegates = (_a = {}, - _a[5] = emitES6Module, - _a[2] = emitAMDModule, - _a[4] = emitSystemModule, - _a[3] = emitUMDModule, - _a[1] = emitCommonJSModule, + _a[ts.ModuleKind.ES6] = emitES6Module, + _a[ts.ModuleKind.AMD] = emitAMDModule, + _a[ts.ModuleKind.System] = emitSystemModule, + _a[ts.ModuleKind.UMD] = emitUMDModule, + _a[ts.ModuleKind.CommonJS] = emitCommonJSModule, _a ); var bundleEmitDelegates = (_b = {}, - _b[5] = function () { }, - _b[2] = emitAMDModule, - _b[4] = emitSystemModule, - _b[3] = function () { }, - _b[1] = function () { }, + _b[ts.ModuleKind.ES6] = function () { }, + _b[ts.ModuleKind.AMD] = emitAMDModule, + _b[ts.ModuleKind.System] = emitSystemModule, + _b[ts.ModuleKind.UMD] = function () { }, + _b[ts.ModuleKind.CommonJS] = function () { }, _b ); return doEmit; @@ -26802,6 +27560,7 @@ var ts; sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); generatedNameSet = {}; nodeToGeneratedName = []; + decoratedClassAliases = []; isOwnFileEmit = !isBundledEmit; if (isBundledEmit && modulekind) { ts.forEach(sourceFiles, emitEmitHelpers); @@ -26819,8 +27578,10 @@ var ts; currentText = undefined; currentLineMap = undefined; exportFunctionForFile = undefined; + contextObjectForFile = undefined; generatedNameSet = undefined; nodeToGeneratedName = undefined; + decoratedClassAliases = undefined; computedPropertyNamesToGeneratedNames = undefined; convertedLoopState = undefined; extendsEmitted = false; @@ -26845,6 +27606,7 @@ var ts; currentText = sourceFile.text; currentLineMap = ts.getLineStarts(sourceFile); exportFunctionForFile = undefined; + contextObjectForFile = undefined; isEs6Module = sourceFile.symbol && sourceFile.symbol.exports && !!sourceFile.symbol.exports["___esModule"]; renamedDependencies = sourceFile.renamedDependencies; currentFileIdentifiers = sourceFile.identifiers; @@ -26859,19 +27621,19 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_22 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_22)) { + var name_21 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_21)) { tempFlags |= flags; - return name_22; + return name_21; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_23 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_23)) { - return name_23; + var name_22 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_22)) { + return name_22; } } } @@ -26909,17 +27671,17 @@ var ts; switch (node.kind) { case 69: return makeUniqueName(node.text); + case 222: case 221: - case 220: return generateNameForModuleOrEnum(node); - case 225: - case 231: + case 226: + case 232: return generateNameForImportOrExportDeclaration(node); - case 216: case 217: - case 230: + case 218: + case 231: return generateNameForExportDefault(); - case 189: + case 190: return generateNameForClassExpression(); } } @@ -27159,10 +27921,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 186) { + if (node.template.kind === 187) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 184 + var needsParens = templateSpan.expression.kind === 185 && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -27186,7 +27948,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 175 + var needsParens = templateSpan.expression.kind !== 176 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -27206,11 +27968,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 171: case 172: - return parent.expression === template; case 173: - case 175: + return parent.expression === template; + case 174: + case 176: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -27218,7 +27980,7 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 184: + case 185: switch (expression.operatorToken.kind) { case 37: case 39: @@ -27230,8 +27992,8 @@ var ts; default: return -1; } - case 187: - case 185: + case 188: + case 186: return -1; default: return 1; @@ -27287,12 +28049,12 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 242; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 243; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; for (var i = 0; i < attrs.length; i++) { - if (attrs[i].kind === 242) { + if (attrs[i].kind === 243) { if (i === 0) { write("{}, "); } @@ -27306,7 +28068,7 @@ var ts; emit(attrs[i].expression); } else { - ts.Debug.assert(attrs[i].kind === 241); + ts.Debug.assert(attrs[i].kind === 242); if (haveOpenedObjectLiteral) { write(", "); } @@ -27336,32 +28098,52 @@ var ts; } } if (children) { - for (var i = 0; i < children.length; i++) { - if (children[i].kind === 243 && !(children[i].expression)) { - continue; - } - if (children[i].kind === 239) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); + var firstChild = void 0; + var multipleEmittableChildren = false; + for (var i = 0, n = children.length; i < n; i++) { + var jsxChild = children[i]; + if (isJsxChildEmittable(jsxChild)) { + if (!firstChild) { + write(", "); + firstChild = jsxChild; + } + else { + if (!multipleEmittableChildren) { + multipleEmittableChildren = true; + increaseIndent(); + writeLine(); + emit(firstChild); + } + write(", "); + writeLine(); + emit(jsxChild); } } + } + if (multipleEmittableChildren) { + decreaseIndent(); + } + else if (firstChild) { + if (firstChild.kind !== 237 && firstChild.kind !== 238) { + emit(firstChild); + } else { - write(", "); - emit(children[i]); + increaseIndent(); + writeLine(); + emit(firstChild); + writeLine(); + decreaseIndent(); } } } write(")"); emitTrailingComments(openingNode); } - if (node.kind === 236) { + if (node.kind === 237) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 237); + ts.Debug.assert(node.kind === 238); emitJsxElement(node); } } @@ -27383,11 +28165,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 242) { + if (attribs[i].kind === 243) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 241); + ts.Debug.assert(attribs[i].kind === 242); emitJsxAttribute(attribs[i]); } } @@ -27395,11 +28177,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 237)) { + if (node.attributes.length > 0 || (node.kind === 238)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 237) { + if (node.kind === 238) { write("/>"); } else { @@ -27418,20 +28200,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 236) { + if (node.kind === 237) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 237); + ts.Debug.assert(node.kind === 238); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 166); + ts.Debug.assert(node.kind !== 167); if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 137) { + else if (node.kind === 138) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -27462,75 +28244,71 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 167: - case 192: - case 184: - case 171: - case 244: - case 137: + case 168: + case 193: case 185: - case 140: - case 178: - case 200: - case 170: - case 230: - case 198: - case 191: - case 202: + case 172: + case 245: + case 138: + case 186: + case 141: + case 179: + case 201: + case 171: + case 231: + case 199: + case 192: case 203: case 204: - case 199: - case 240: - case 237: + case 205: + case 200: + case 241: case 238: - case 242: + case 239: case 243: - case 172: - case 175: - case 183: - case 182: - case 207: - case 249: - case 188: - case 209: + case 244: case 173: - case 193: - case 211: - case 174: - case 179: - case 180: - case 201: - case 208: - case 187: - return true; - case 166: - case 250: - case 139: - case 248: - case 142: - case 214: - return parent.initializer === node; - case 169: - return parent.expression === node; - case 177: case 176: + case 184: + case 183: + case 208: + case 250: + case 189: + case 210: + case 174: + case 194: + case 212: + case 175: + case 180: + case 181: + case 202: + case 209: + case 188: + return true; + case 167: + case 251: + case 140: + case 249: + case 143: + case 215: + return parent.initializer === node; + case 170: + return parent.expression === node; + case 178: + case 177: return parent.body === node; - case 224: + case 225: return parent.moduleReference === node; - case 136: + case 137: return parent.left === node; } return false; } function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048) { - write("_arguments"); - return; - } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 251) { - if (modulekind !== 5 && modulekind !== 4) { + if (container.kind === 252) { + if (modulekind !== ts.ModuleKind.ES6 && modulekind !== ts.ModuleKind.System) { write("exports."); } } @@ -27540,18 +28318,18 @@ var ts; } } else { - if (modulekind !== 5) { + if (modulekind !== ts.ModuleKind.ES6) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 226) { + if (declaration.kind === 227) { write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 229) { + else if (declaration.kind === 230) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_24 = declaration.propertyName || declaration.name; - var identifier = ts.getTextOfNodeFromSourceText(currentText, name_24); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getTextOfNodeFromSourceText(currentText, name_23); if (languageVersion === 0 && identifier === "default") { write("[\"default\"]"); } @@ -27563,13 +28341,23 @@ var ts; } } } - if (languageVersion !== 2) { - var declaration = resolver.getReferencedNestedRedeclaration(node); + if (languageVersion < 2) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration) { write(getGeneratedNameForNode(declaration.name)); return; } } + else if (resolver.getNodeCheckFlags(node) & 1048576) { + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration) { + var classAlias = decoratedClassAliases[ts.getNodeId(declaration)]; + if (classAlias !== undefined) { + write(classAlias); + return; + } + } + } } if (ts.nodeIsSynthesized(node)) { write(node.text); @@ -27578,15 +28366,15 @@ var ts; writeTextOfNode(currentText, node); } } - function isNameOfNestedRedeclaration(node) { + function isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node) { if (languageVersion < 2) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 166: - case 217: - case 220: - case 214: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_8 = node.parent; + switch (parent_8.kind) { + case 167: + case 218: + case 221: + case 215: + return parent_8.name === node && resolver.isDeclarationWithCollidingName(parent_8); } } return false; @@ -27594,8 +28382,8 @@ var ts; function emitIdentifier(node) { if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { - var name_25 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); - write(name_25); + var name_24 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_24); return; } } @@ -27605,7 +28393,7 @@ var ts; else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } - else if (isNameOfNestedRedeclaration(node)) { + else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { write(getGeneratedNameForNode(node)); } else if (ts.nodeIsSynthesized(node)) { @@ -27695,10 +28483,10 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 184 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 185 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 185 && node.parent.condition === node) { + else if (node.parent.kind === 186 && node.parent.condition === node) { return true; } return false; @@ -27706,11 +28494,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 69: - case 167: - case 169: + case 168: case 170: case 171: - case 175: + case 172: + case 176: return false; } return true; @@ -27727,17 +28515,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 188) { + if (e.kind === 189) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 167) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 168) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 188) { + while (i < length && elements[i].kind !== 189) { i++; } write("["); @@ -27760,7 +28548,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 188; + return node.kind === 189; } function emitArrayLiteral(node) { var elements = node.elements; @@ -27773,7 +28561,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 1024) !== 0, elements.hasTrailingComma, true); + emitListWithSpread(elements, true, node.multiLine, elements.hasTrailingComma, true); } } function emitObjectLiteralBody(node, numElements) { @@ -27788,7 +28576,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1, true); } else { - var multiLine = (node.flags & 1024) !== 0; + var multiLine = node.multiLine; if (!multiLine) { write(" "); } @@ -27807,7 +28595,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 1024) !== 0; + var multiLine = node.multiLine; var properties = node.properties; write("("); if (multiLine) { @@ -27821,7 +28609,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 146 || property.kind === 147) { + if (property.kind === 147 || property.kind === 148) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -27872,13 +28660,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 248) { + if (property.kind === 249) { emit(property.initializer); } - else if (property.kind === 249) { + else if (property.kind === 250) { emitExpressionIdentifier(property.name); } - else if (property.kind === 144) { + else if (property.kind === 145) { emitFunctionDeclaration(property); } else { @@ -27910,7 +28698,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 === 137) { + if (properties[i].name.kind === 138) { numInitialNonComputedProperties = i; break; } @@ -27924,35 +28712,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(184, startsOnNewLine); + var result = ts.createSynthesizedNode(185, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(169); + var result = ts.createSynthesizedNode(170); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(170); + var result = ts.createSynthesizedNode(171); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 174 || expr.kind === 192) { + while (expr.kind === 175 || expr.kind === 193) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 172 && + expr.kind !== 173 && expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(175); + var node = ts.createSynthesizedNode(176); node.expression = expr; return node; } @@ -27979,11 +28767,11 @@ var ts; } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 251; + return container && container.kind !== 252; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentText, node.name); - if (modulekind !== 5 || isNamespaceExportReference(node.name)) { + if (modulekind !== ts.ModuleKind.ES6 || isNamespaceExportReference(node.name)) { write(": "); emit(node.name); } @@ -27997,7 +28785,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 169 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 170 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -28008,7 +28796,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 169 || node.kind === 170 + return node.kind === 170 || node.kind === 171 ? resolver.getConstantValue(node) : undefined; } @@ -28031,6 +28819,14 @@ var ts; if (tryEmitConstantValue(node)) { return; } + if (languageVersion === 2 && + node.expression.kind === 95 && + isInAsyncMethodWithSuperInES6(node)) { + var name_25 = ts.createSynthesizedNode(9); + name_25.text = node.name.text; + emitSuperAccessInAsyncMethod(node.expression, name_25); + return; + } emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); var shouldEmitSpace = false; @@ -28088,7 +28884,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 136: + case 137: emitQualifiedNameAsExpression(node, useFallback); break; default: @@ -28100,16 +28896,22 @@ var ts; if (tryEmitConstantValue(node)) { return; } + if (languageVersion === 2 && + node.expression.kind === 95 && + isInAsyncMethodWithSuperInES6(node)) { + emitSuperAccessInAsyncMethod(node.expression, node.argumentExpression); + return; + } emit(node.expression); write("["); emit(node.argumentExpression); write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 188; }); + return ts.forEach(elements, function (e) { return e.kind === 189; }); } function skipParentheses(node) { - while (node.kind === 175 || node.kind === 174 || node.kind === 192) { + while (node.kind === 176 || node.kind === 175 || node.kind === 193) { node = node.expression; } return node; @@ -28130,12 +28932,12 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 169) { + if (expr.kind === 170) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 170) { + else if (expr.kind === 171) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); @@ -28164,23 +28966,42 @@ var ts; emitListWithSpread(node.arguments, false, false, false, true); write(")"); } + function isInAsyncMethodWithSuperInES6(node) { + if (languageVersion === 2) { + var container = ts.getSuperContainer(node, false); + if (container && resolver.getNodeCheckFlags(container) & (2048 | 4096)) { + return true; + } + } + return false; + } + function emitSuperAccessInAsyncMethod(superNode, argumentExpression) { + var container = ts.getSuperContainer(superNode, false); + var isSuperBinding = resolver.getNodeCheckFlags(container) & 4096; + write("_super("); + emit(argumentExpression); + write(isSuperBinding ? ").value" : ")"); + } function emitCallExpression(node) { if (languageVersion < 2 && hasSpreadElement(node.arguments)) { emitCallWithSpread(node); return; } + var expression = node.expression; var superCall = false; - if (node.expression.kind === 95) { - emitSuper(node.expression); + var isAsyncMethodWithSuper = false; + if (expression.kind === 95) { + emitSuper(expression); superCall = true; } else { - emit(node.expression); - superCall = node.expression.kind === 169 && node.expression.expression.kind === 95; + superCall = ts.isSuperPropertyOrElementAccess(expression); + isAsyncMethodWithSuper = superCall && isInAsyncMethodWithSuperInES6(node); + emit(expression); } - if (superCall && languageVersion < 2) { + if (superCall && (languageVersion < 2 || isAsyncMethodWithSuper)) { write(".call("); - emitThis(node.expression); + emitThis(expression); if (node.arguments.length) { write(", "); emitCommaList(node.arguments); @@ -28227,21 +29048,21 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 177) { - if (node.expression.kind === 174 || node.expression.kind === 192) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 178) { + if (node.expression.kind === 175 || node.expression.kind === 193) { var operand = node.expression.expression; - while (operand.kind === 174 || operand.kind === 192) { + while (operand.kind === 175 || operand.kind === 193) { operand = operand.expression; } - if (operand.kind !== 182 && + if (operand.kind !== 183 && + operand.kind !== 181 && operand.kind !== 180 && operand.kind !== 179 && - operand.kind !== 178 && - operand.kind !== 183 && - operand.kind !== 172 && - !(operand.kind === 171 && node.parent.kind === 172) && - !(operand.kind === 176 && node.parent.kind === 171) && - !(operand.kind === 8 && node.parent.kind === 169)) { + operand.kind !== 184 && + operand.kind !== 173 && + !(operand.kind === 172 && node.parent.kind === 173) && + !(operand.kind === 177 && node.parent.kind === 172) && + !(operand.kind === 8 && node.parent.kind === 170)) { emit(operand); return; } @@ -28270,7 +29091,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 69 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 214 || node.parent.kind === 166); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 215 || node.parent.kind === 167); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -28285,7 +29106,7 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 182) { + if (node.operand.kind === 183) { var operand = node.operand; if (node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) { write(" "); @@ -28326,12 +29147,12 @@ var ts; if (!node || !isCurrentFileSystemExternalModule()) { return false; } - var current = node; + var current = ts.getRootDeclaration(node).parent; while (current) { - if (current.kind === 251) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 2) !== 0); + if (current.kind === 252) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 222) { + else if (ts.isDeclaration(current)) { return false; } else { @@ -28342,12 +29163,12 @@ var ts; function emitExponentiationOperator(node) { var leftHandSideExpression = node.left; if (node.operatorToken.kind === 60) { - var synthesizedLHS; + var synthesizedLHS = void 0; var shouldEmitParentheses = false; if (ts.isElementAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(170, false); + synthesizedLHS = ts.createSynthesizedNode(171, false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); synthesizedLHS.expression = identifier; if (leftHandSideExpression.argumentExpression.kind !== 8 && @@ -28364,7 +29185,7 @@ var ts; else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(169, false); + synthesizedLHS = ts.createSynthesizedNode(170, false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, false, false); synthesizedLHS.expression = identifier; synthesizedLHS.dotToken = leftHandSideExpression.dotToken; @@ -28392,8 +29213,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 && node.operatorToken.kind === 56 && - (node.left.kind === 168 || node.left.kind === 167)) { - emitDestructuring(node, node.parent.kind === 198); + (node.left.kind === 169 || node.left.kind === 168)) { + emitDestructuring(node, node.parent.kind === 199); } else { var exportChanged = node.operatorToken.kind >= 56 && @@ -28445,7 +29266,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 195) { + if (node && node.kind === 196) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -28459,12 +29280,12 @@ var ts; } emitToken(15, node.pos); increaseIndent(); - if (node.kind === 222) { - ts.Debug.assert(node.parent.kind === 221); + if (node.kind === 223) { + ts.Debug.assert(node.parent.kind === 222); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 222) { + if (node.kind === 223) { emitTempDeclarations(true); } decreaseIndent(); @@ -28472,7 +29293,7 @@ var ts; emitToken(16, node.statements.end); } function emitEmbeddedStatement(node) { - if (node.kind === 195) { + if (node.kind === 196) { write(" "); emit(node); } @@ -28484,7 +29305,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 177); + emitParenthesizedIf(node.expression, node.expression.kind === 178); write(";"); } function emitIfStatement(node) { @@ -28497,7 +29318,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(80, node.thenStatement.end); - if (node.elseStatement.kind === 199) { + if (node.elseStatement.kind === 200) { write(" "); emit(node.elseStatement); } @@ -28517,7 +29338,7 @@ var ts; else { emitNormalLoopBody(node, true); } - if (node.statement.kind === 195) { + if (node.statement.kind === 196) { write(" "); } else { @@ -28545,7 +29366,7 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 3072) === 0) { for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { var varDecl = _b[_a]; hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); @@ -28597,7 +29418,7 @@ var ts; } else { var loop = convertLoopBody(node); - if (node.parent.kind === 210) { + if (node.parent.kind === 211) { emitLabelAndColon(node.parent); } loopEmitter(node, loop); @@ -28607,34 +29428,30 @@ var ts; var functionName = makeUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 202: case 203: case 204: + case 205: var initializer = node.initializer; - if (initializer && initializer.kind === 215) { + if (initializer && initializer.kind === 216) { loopInitializer = node.initializer; } break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576)) { + var loopOutParameters; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3072)) { loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { var varDeclaration = _b[_a]; - collectNames(varDeclaration.name); + processVariableDeclaration(varDeclaration.name); } } - var bodyIsBlock = node.statement.kind === 195; + var bodyIsBlock = node.statement.kind === 196; var paramList = loopParameters ? loopParameters.join(", ") : ""; writeLine(); write("var " + functionName + " = function(" + paramList + ")"); - if (!bodyIsBlock) { - write(" {"); - writeLine(); - increaseIndent(); - } var convertedOuterLoopState = convertedLoopState; - convertedLoopState = {}; + convertedLoopState = { loopOutParameters: loopOutParameters }; if (convertedOuterLoopState) { if (convertedOuterLoopState.argumentsName) { convertedLoopState.argumentsName = convertedOuterLoopState.argumentsName; @@ -28646,14 +29463,32 @@ var ts; convertedLoopState.hoistedLocalVariables = convertedOuterLoopState.hoistedLocalVariables; } } - emitEmbeddedStatement(node.statement); - if (!bodyIsBlock) { - decreaseIndent(); - writeLine(); - write("}"); - } - write(";"); + write(" {"); writeLine(); + increaseIndent(); + if (bodyIsBlock) { + emitLines(node.statement.statements); + } + else { + emit(node.statement); + } + writeLine(); + copyLoopOutParameters(convertedLoopState, 1, true); + decreaseIndent(); + writeLine(); + write("};"); + writeLine(); + if (loopOutParameters) { + write("var "); + for (var i = 0; i < loopOutParameters.length; i++) { + if (i !== 0) { + write(", "); + } + write(loopOutParameters[i].outParamName); + } + write(";"); + writeLine(); + } if (convertedLoopState.argumentsName) { if (convertedOuterLoopState) { convertedOuterLoopState.argumentsName = convertedLoopState.argumentsName; @@ -28678,7 +29513,7 @@ var ts; } else { write("var "); - var seen; + var seen = void 0; for (var _c = 0, _d = convertedLoopState.hoistedLocalVariables; _c < _d.length; _c++) { var id = _d[_c]; if (!seen) { @@ -28699,15 +29534,21 @@ var ts; var currentLoopState = convertedLoopState; convertedLoopState = convertedOuterLoopState; return { functionName: functionName, paramList: paramList, state: currentLoopState }; - function collectNames(name) { + function processVariableDeclaration(name) { if (name.kind === 69) { - var nameText = isNameOfNestedRedeclaration(name) ? getGeneratedNameForNode(name) : name.text; + var nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(name) + ? getGeneratedNameForNode(name) + : name.text; loopParameters.push(nameText); + if (resolver.getNodeCheckFlags(name.parent) & 2097152) { + var reassignedVariable = { originalName: name, outParamName: makeUniqueName("out_" + nameText) }; + (loopOutParameters || (loopOutParameters = [])).push(reassignedVariable); + } } else { for (var _a = 0, _b = name.elements; _a < _b.length; _a++) { var element = _b[_a]; - collectNames(element.name); + processVariableDeclaration(element.name); } } } @@ -28721,7 +29562,7 @@ var ts; if (emitAsEmbeddedStatement) { emitEmbeddedStatement(node.statement); } - else if (node.statement.kind === 195) { + else if (node.statement.kind === 196) { emitLines(node.statement.statements); } else { @@ -28732,6 +29573,28 @@ var ts; convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } } + function copyLoopOutParameters(state, copyDirection, emitAsStatements) { + if (state.loopOutParameters) { + for (var _a = 0, _b = state.loopOutParameters; _a < _b.length; _a++) { + var outParam = _b[_a]; + if (copyDirection === 0) { + emitIdentifier(outParam.originalName); + write(" = " + outParam.outParamName); + } + else { + write(outParam.outParamName + " = "); + emitIdentifier(outParam.originalName); + } + if (emitAsStatements) { + write(";"); + writeLine(); + } + else { + write(", "); + } + } + } + } function emitConvertedLoopCall(loop, emitAsBlock) { if (emitAsBlock) { write(" {"); @@ -28746,6 +29609,8 @@ var ts; write("var " + loopResult + " = "); } write(loop.functionName + "(" + loop.paramList + ");"); + writeLine(); + copyLoopOutParameters(loop.state, 0, true); if (!isSimpleLoop) { writeLine(); if (loop.state.nonLocalJumps & 8) { @@ -28755,7 +29620,7 @@ var ts; convertedLoopState.nonLocalJumps |= 8; } else { - write("return " + loopResult + ".value"); + write("return " + loopResult + ".value;"); } writeLine(); } @@ -28817,7 +29682,7 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer && node.initializer.kind === 215) { + if (node.initializer && node.initializer.kind === 216) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList); if (startIsEmitted) { @@ -28843,7 +29708,7 @@ var ts; } } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 204) { + if (languageVersion < 2 && node.kind === 205) { emitLoop(node, emitDownLevelForOfStatementWorker); } else { @@ -28854,7 +29719,7 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList); @@ -28864,7 +29729,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 203) { + if (node.kind === 204) { write(" in "); } else { @@ -28917,7 +29782,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 215) { + if (node.initializer.kind === 216) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -28939,7 +29804,7 @@ var ts; } else { var assignmentExpression = createBinaryExpression(node.initializer, 56, rhsIterationValue, false); - if (node.initializer.kind === 167 || node.initializer.kind === 168) { + if (node.initializer.kind === 168 || node.initializer.kind === 169) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -28961,23 +29826,25 @@ var ts; } function emitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 206 ? 2 : 4; + var jump = node.kind === 207 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { + write("return "); + copyLoopOutParameters(convertedLoopState, 1, false); if (!node.label) { - if (node.kind === 206) { + if (node.kind === 207) { convertedLoopState.nonLocalJumps |= 2; - write("return \"break\";"); + write("\"break\";"); } else { convertedLoopState.nonLocalJumps |= 4; - write("return \"continue\";"); + write("\"continue\";"); } } else { - var labelMarker; - if (node.kind === 206) { + var labelMarker = void 0; + if (node.kind === 207) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -28985,12 +29852,12 @@ var ts; labelMarker = "continue-" + node.label.text; setLabeledJump(convertedLoopState, false, node.label.text, labelMarker); } - write("return \"" + labelMarker + "\";"); + write("\"" + labelMarker + "\";"); } return; } } - emitToken(node.kind === 206 ? 70 : 75, node.pos); + emitToken(node.kind === 207 ? 70 : 75, node.pos); emitOptional(" ", node.label); write(";"); } @@ -29055,7 +29922,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap(currentLineMap, ts.skipTrivia(currentText, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 244) { + if (node.kind === 245) { write("case "); emit(node.expression); write(":"); @@ -29124,7 +29991,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 221); + } while (node && node.kind !== 222); return node; } function emitContainingModuleName(node) { @@ -29133,13 +30000,13 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 2) { + if (ts.getCombinedNodeFlags(node) & 1) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); write("."); } - else if (modulekind !== 5 && modulekind !== 4) { + else if (modulekind !== ts.ModuleKind.ES6 && modulekind !== ts.ModuleKind.System) { write("exports."); } } @@ -29149,14 +30016,14 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(180); + var result = ts.createSynthesizedNode(181); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 251) { - ts.Debug.assert(!!(node.flags & 512) || node.kind === 230); - if (modulekind === 1 || modulekind === 2 || modulekind === 3) { + if (node.parent.kind === 252) { + ts.Debug.assert(!!(node.flags & 512) || node.kind === 231); + if (modulekind === ts.ModuleKind.CommonJS || modulekind === ts.ModuleKind.AMD || modulekind === ts.ModuleKind.UMD) { if (!isEs6Module) { if (languageVersion !== 0) { write("Object.defineProperty(exports, \"__esModule\", { value: true });"); @@ -29171,10 +30038,10 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 2) { + if (node.flags & 1) { writeLine(); emitStart(node); - if (modulekind === 4 && node.parent === currentSourceFile) { + if (modulekind === ts.ModuleKind.System && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); if (node.flags & 512) { write("default"); @@ -29207,7 +30074,7 @@ var ts; } } function emitExportMemberAssignments(name) { - if (modulekind === 4) { + if (modulekind === ts.ModuleKind.System) { return; } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { @@ -29226,7 +30093,7 @@ var ts; } } function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(modulekind === 4); + ts.Debug.assert(modulekind === ts.ModuleKind.System); if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { return; } @@ -29250,7 +30117,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 214 || name.parent.kind === 166); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 215 || name.parent.kind === 167); emitStart(isFirstVariableDeclaration(nodeForSourceMap) ? nodeForSourceMap.parent : nodeForSourceMap); withTemporaryNoSourceMap(function () { if (isVariableDeclarationOrBindingElement) { @@ -29276,22 +30143,22 @@ var ts; return identifier; } function isFirstVariableDeclaration(root) { - return root.kind === 214 && - root.parent.kind === 215 && + return root.kind === 215 && + root.parent.kind === 216 && root.parent.declarations[0] === root; } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 214) { - var isExported = ts.getCombinedNodeFlags(root) & 2; + if (root.kind === 215) { + var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 139) { + else if (root.kind === 140) { canDefineTempVariablesInPlace = true; } - if (root.kind === 184) { + if (root.kind === 185) { emitAssignmentExpression(root); } else { @@ -29311,14 +30178,14 @@ var ts; } function createDefaultValueCheck(value, defaultValue, sourceMapNode) { value = ensureIdentifier(value, true, sourceMapNode); - var equals = ts.createSynthesizedNode(184); + var equals = ts.createSynthesizedNode(185); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(185); + var cond = ts.createSynthesizedNode(186); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(53); cond.whenTrue = whenTrue; @@ -29333,20 +30200,20 @@ var ts; } function createPropertyAccessForDestructuringProperty(object, propName) { var index; - var nameIsComputed = propName.kind === 137; + var nameIsComputed = propName.kind === 138; if (nameIsComputed) { index = ensureIdentifier(propName.expression, false, propName); } else { index = ts.createSynthesizedNode(propName.kind); - index.text = propName.text; + index.text = ts.unescapeIdentifier(propName.text); } return !nameIsComputed && index.kind === 69 ? createPropertyAccessExpression(object, index) : createElementAccessExpression(object, index); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(171); + var call = ts.createSynthesizedNode(172); var sliceIdentifier = ts.createSynthesizedNode(69); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -29361,9 +30228,9 @@ var ts; } for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { var p = properties_5[_a]; - if (p.kind === 248 || p.kind === 249) { + if (p.kind === 249 || p.kind === 250) { var propName = p.name; - var target_1 = p.kind === 249 ? p : p.initializer || propName; + var target_1 = p.kind === 250 ? p : p.initializer || propName; emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName), p); } } @@ -29375,8 +30242,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 190) { - if (e.kind !== 188) { + if (e.kind !== 191) { + if (e.kind !== 189) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)), e); } else if (i === elements.length - 1) { @@ -29386,20 +30253,20 @@ var ts; } } function emitDestructuringAssignment(target, value, sourceMapNode) { - if (target.kind === 249) { + if (target.kind === 250) { if (target.objectAssignmentInitializer) { value = createDefaultValueCheck(value, target.objectAssignmentInitializer, sourceMapNode); } target = target.name; } - else if (target.kind === 184 && target.operatorToken.kind === 56) { + else if (target.kind === 185 && target.operatorToken.kind === 56) { value = createDefaultValueCheck(value, target.right, sourceMapNode); target = target.left; } - if (target.kind === 168) { + if (target.kind === 169) { emitObjectLiteralAssignment(target, value, sourceMapNode); } - else if (target.kind === 167) { + else if (target.kind === 168) { emitArrayLiteralAssignment(target, value, sourceMapNode); } else { @@ -29417,14 +30284,14 @@ var ts; emitDestructuringAssignment(target, value, ts.nodeIsSynthesized(root) ? target : root); } else { - if (root.parent.kind !== 175) { + if (root.parent.kind !== 176) { write("("); } value = ensureIdentifier(value, true, root); emitDestructuringAssignment(target, value, root); write(", "); emit(value); - if (root.parent.kind !== 175) { + if (root.parent.kind !== 176) { write(")"); } } @@ -29445,11 +30312,11 @@ var ts; } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 164) { + if (pattern.kind === 165) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 190) { + else if (element.kind !== 191) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -29477,12 +30344,23 @@ var ts; } else { var initializer = node.initializer; - if (!initializer && languageVersion < 2) { - var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 8192); - if (isLetDefinedInLoop && - node.parent.parent.kind !== 203 && - node.parent.parent.kind !== 204) { + if (!initializer && + languageVersion < 2 && + node.name.kind === 69) { + var container = ts.getEnclosingBlockScopeContainer(node); + var flags = resolver.getNodeCheckFlags(node); + var isCapturedInFunction = flags & 131072; + var isDeclaredInLoop = flags & 262144; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(container) || + (isCapturedInFunction && isDeclaredInLoop && container.kind === 196 && ts.isIterationStatement(container.parent, false)); + var emittedAsNestedLetDeclaration = ts.getCombinedNodeFlags(node) & 1024 && + !emittedAsTopLevel; + var emitExplicitInitializer = emittedAsNestedLetDeclaration && + container.kind !== 204 && + container.kind !== 205 && + (!resolver.isDeclarationWithCollidingName(node) || + (isDeclaredInLoop && !isCapturedInFunction && !ts.isIterationStatement(container, false))); + if (emitExplicitInitializer) { initializer = createVoidZero(); } } @@ -29500,7 +30378,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 190) { + if (node.kind === 191) { return; } var name = node.name; @@ -29511,20 +30389,14 @@ var ts; ts.forEach(name.elements, emitExportVariableAssignments); } } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 214 && node.parent.kind !== 166)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } function isES6ExportedDeclaration(node) { - return !!(node.flags & 2) && - modulekind === 5 && - node.parent.kind === 251; + return !!(node.flags & 1) && + modulekind === ts.ModuleKind.ES6 && + node.parent.kind === 252; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 2) { + if (node.flags & 1) { if (isES6ExportedDeclaration(node)) { write("export "); startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); @@ -29543,12 +30415,12 @@ var ts; write(";"); } } - if (modulekind !== 5 && node.parent === currentSourceFile) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } } function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 2)) { + if (!(node.flags & 1)) { return true; } if (isES6ExportedDeclaration(node)) { @@ -29586,7 +30458,7 @@ var ts; } function emitDefaultValueAssignments(node) { if (languageVersion < 2) { - var tempIndex = 0; + var tempIndex_1 = 0; ts.forEach(node.parameters, function (parameter) { if (parameter.dotDotDotToken) { return; @@ -29598,15 +30470,15 @@ var ts; writeLine(); write("var "); if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); + emitDestructuring(parameter, false, tempParameters[tempIndex_1]); } else { - emit(tempParameters[tempIndex]); + emit(tempParameters[tempIndex_1]); write(" = "); emit(initializer); } write(";"); - tempIndex++; + tempIndex_1++; } } else if (initializer) { @@ -29669,12 +30541,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 146 ? "get " : "set "); + write(node.kind === 147 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 177 && languageVersion >= 2; + return node.kind === 178 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -29685,11 +30557,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 176) { + if (node.kind === 177) { return !!node.name; } - if (node.kind === 216) { - return !!node.name || modulekind !== 5; + if (node.kind === 217) { + return !!node.name || modulekind !== ts.ModuleKind.ES6; } } function emitFunctionDeclaration(node) { @@ -29697,12 +30569,12 @@ var ts; return emitCommentsOnNotEmittedNode(node); } var kind = node.kind, parent = node.parent; - if (kind !== 144 && - kind !== 143 && + if (kind !== 145 && + kind !== 144 && parent && - parent.kind !== 248 && - parent.kind !== 171 && - parent.kind !== 167) { + parent.kind !== 249 && + parent.kind !== 172 && + parent.kind !== 168) { emitLeadingComments(node); } emitStart(node); @@ -29723,11 +30595,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (modulekind !== 5 && kind === 216 && parent === currentSourceFile && node.name) { + if (modulekind !== ts.ModuleKind.ES6 && kind === 217 && parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (kind !== 144 && kind !== 143) { + if (kind !== 145 && kind !== 144) { emitTrailingComments(node); } } @@ -29759,12 +30631,20 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 177; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; + var isArrowFunction = node.kind === 178; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { write(" {"); increaseIndent(); writeLine(); + if (resolver.getNodeCheckFlags(node) & 4096) { + writeLines("\nconst _super = (function (geti, seti) {\n const cache = Object.create(null);\n return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });\n})(name => super[name], (name, value) => super[name] = value);"); + writeLine(); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + write("const _super = name => super[name];"); + writeLine(); + } write("return"); } write(" __awaiter(this"); @@ -29774,18 +30654,13 @@ var ts; else { write(", void 0, "); } - if (promiseConstructor) { + if (languageVersion >= 2 || !promiseConstructor) { + write("void 0"); + } + else { emitEntityNameAsExpression(promiseConstructor, false); } - else { - write("Promise"); - } - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } + write(", function* ()"); emitFunctionBody(node); write(")"); if (!isArrowFunction) { @@ -29800,7 +30675,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 195) { + if (node.body.kind === 196) { emitBlockFunctionBody(node, node.body); } else { @@ -29852,10 +30727,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 174) { + while (current.kind === 175) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 168); + emitParenthesizedIf(body, current.kind === 169); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -29922,23 +30797,22 @@ var ts; } emitToken(16, body.statements.end); } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 198) { - var expr = statement.expression; - if (expr && expr.kind === 171) { - var func = expr.expression; - if (func && func.kind === 95) { - return statement; - } - } - } + function getSuperCallAtGivenIndex(ctor, index) { + if (!ctor.body) { + return undefined; + } + var statements = ctor.body.statements; + if (!statements || index >= statements.length) { + return undefined; + } + var statement = statements[index]; + if (statement.kind === 199) { + return ts.isSuperCallExpression(statement.expression) ? statement : undefined; } } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 56) { + if (param.flags & 28) { writeLine(); emitStart(param); emitStart(param.name); @@ -29958,7 +30832,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 137) { + else if (memberName.kind === 138) { emitComputedPropertyName(memberName); } else { @@ -29970,7 +30844,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 142 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { + if (member.kind === 143 && isStatic === ((member.flags & 32) !== 0) && member.initializer) { properties.push(member); } } @@ -29991,7 +30865,7 @@ var ts; emit(receiver); } else { - if (property.flags & 64) { + if (property.flags & 32) { emitDeclarationName(node); } else { @@ -30010,11 +30884,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 194) { + if (member.kind === 195) { writeLine(); write(";"); } - else if (member.kind === 144 || node.kind === 143) { + else if (member.kind === 145 || node.kind === 144) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -30031,7 +30905,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 146 || member.kind === 147) { + else if (member.kind === 147 || member.kind === 148) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -30081,22 +30955,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 144 || node.kind === 143) && !member.body) { + if ((member.kind === 145 || node.kind === 144) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 144 || - member.kind === 146 || - member.kind === 147) { + else if (member.kind === 145 || + member.kind === 147 || + member.kind === 148) { writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 64) { + if (member.flags & 32) { write("static "); } - if (member.kind === 146) { + if (member.kind === 147) { write("get "); } - else if (member.kind === 147) { + else if (member.kind === 148) { write("set "); } if (member.asteriskToken) { @@ -30107,7 +30981,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 194) { + else if (member.kind === 195) { writeLine(); write(";"); } @@ -30132,10 +31006,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 145 && !member.body) { + if (member.kind === 146 && !member.body) { emitCommentsOnNotEmittedNode(member); } - if (member.kind === 142 && member.initializer && (member.flags & 64) === 0) { + if (member.kind === 143 && member.initializer && (member.flags & 32) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -30179,7 +31053,7 @@ var ts; emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); + superCall = getSuperCallAtGivenIndex(ctor, startIndex); if (superCall) { writeLine(); emit(superCall); @@ -30233,19 +31107,29 @@ var ts; else { emitClassLikeDeclarationForES6AndHigher(node); } - if (modulekind !== 5 && node.parent === currentSourceFile && node.name) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } } function emitClassLikeDeclarationForES6AndHigher(node) { + var decoratedClassAlias; var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 217) { + if (node.kind === 218) { if (thisNodeIsDecorated) { + if (resolver.getNodeCheckFlags(node) & 524288) { + decoratedClassAlias = ts.unescapeIdentifier(makeUniqueName(node.name ? node.name.text : "default")); + decoratedClassAliases[ts.getNodeId(node)] = decoratedClassAlias; + write("let " + decoratedClassAlias + ";"); + writeLine(); + } if (isES6ExportedDeclaration(node) && !(node.flags & 512)) { write("export "); } write("let "); emitDeclarationName(node); + if (decoratedClassAlias !== undefined) { + write(" = " + decoratedClassAlias); + } write(" = "); } else if (isES6ExportedDeclaration(node)) { @@ -30256,7 +31140,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 189; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 190; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -30266,7 +31150,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || (node.flags & 512 && (staticProperties.length > 0 || modulekind !== 5))) && !thisNodeIsDecorated) { + if (node.name || (node.flags & 512 && (staticProperties.length > 0 || modulekind !== ts.ModuleKind.ES6) && !thisNodeIsDecorated)) { write(" "); emitDeclarationName(node); } @@ -30284,6 +31168,7 @@ var ts; writeLine(); emitToken(16, node.members.end); if (thisNodeIsDecorated) { + decoratedClassAliases[ts.getNodeId(node)] = undefined; write(";"); } if (isClassExpressionWithStaticProperties) { @@ -30302,12 +31187,12 @@ var ts; else { writeLine(); emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); + emitDecoratorsOfClass(node, decoratedClassAlias); } - if (!(node.flags & 2)) { + if (!(node.flags & 1)) { return; } - if (modulekind !== 5) { + if (modulekind !== ts.ModuleKind.ES6) { emitExportMemberAssignment(node); } else { @@ -30319,7 +31204,7 @@ var ts; write(";"); } } - else if (node.parent.kind !== 251) { + else if (node.parent.kind !== 252) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -30331,7 +31216,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 217) { + if (node.kind === 218) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -30368,7 +31253,7 @@ var ts; emitMemberFunctionsForES5AndLower(node); emitPropertyDeclarations(node, getInitializedProperties(node, true)); writeLine(); - emitDecoratorsOfClass(node); + emitDecoratorsOfClass(node, undefined); writeLine(); emitToken(16, node.members.end, function () { write("return "); @@ -30391,26 +31276,26 @@ var ts; emit(baseTypeNode.expression); } write("))"); - if (node.kind === 217) { + if (node.kind === 218) { write(";"); } emitEnd(node); - if (node.kind === 217) { + if (node.kind === 218) { emitExportMemberAssignment(node); } } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 64)) { + if (!(member.flags & 32)) { write(".prototype"); } } - function emitDecoratorsOfClass(node) { + function emitDecoratorsOfClass(node, decoratedClassAlias) { emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 64); - emitDecoratorsOfConstructor(node); + emitDecoratorsOfMembers(node, 32); + emitDecoratorsOfConstructor(node, decoratedClassAlias); } - function emitDecoratorsOfConstructor(node) { + function emitDecoratorsOfConstructor(node, decoratedClassAlias) { var decorators = node.decorators; var constructor = ts.getFirstConstructorWithBody(node); var firstParameterDecorator = constructor && ts.forEach(constructor.parameters, function (parameter) { return parameter.decorators; }); @@ -30420,6 +31305,9 @@ var ts; writeLine(); emitStart(node.decorators || firstParameterDecorator); emitDeclarationName(node); + if (decoratedClassAlias !== undefined) { + write(" = " + decoratedClassAlias); + } write(" = __decorate(["); increaseIndent(); writeLine(); @@ -30441,7 +31329,7 @@ var ts; function emitDecoratorsOfMembers(node, staticFlag) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.flags & 64) !== staticFlag) { + if ((member.flags & 32) !== staticFlag) { continue; } if (!ts.nodeCanBeDecorated(member)) { @@ -30462,7 +31350,7 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 144) { + if (member.kind === 145) { functionLikeMember = member; } } @@ -30488,7 +31376,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); if (languageVersion > 0) { - if (member.kind !== 142) { + if (member.kind !== 143) { write(", null"); } else { @@ -30504,64 +31392,64 @@ var ts; function emitDecoratorsOfParameters(node, leadingComma) { var argumentsWritten = 0; if (node) { - var parameterIndex = 0; + var parameterIndex_1 = 0; for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { var parameter = _b[_a]; if (ts.nodeIsDecorated(parameter)) { var decorators = parameter.decorators; argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { - write("__param(" + parameterIndex + ", "); + write("__param(" + parameterIndex_1 + ", "); emit(decorator.expression); write(")"); }); leadingComma = true; } - parameterIndex++; + parameterIndex_1++; } } return argumentsWritten; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 144: - case 146: + case 145: case 147: - case 142: + case 148: + case 143: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 144: + case 145: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 217: - case 144: - case 147: + case 218: + case 145: + case 148: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 217: + case 218: write("Function"); return; - case 142: + case 143: emitSerializedTypeNode(node.type); return; - case 139: - emitSerializedTypeNode(node.type); - return; - case 146: + case 140: emitSerializedTypeNode(node.type); return; case 147: + emitSerializedTypeNode(node.type); + return; + case 148: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -30577,40 +31465,40 @@ var ts; case 103: write("void 0"); return; - case 161: + case 162: emitSerializedTypeNode(node.type); return; - case 153: case 154: + case 155: write("Function"); return; - case 157: case 158: + case 159: write("Array"); return; - case 151: + case 152: case 120: write("Boolean"); return; - case 130: - case 163: + case 131: + case 164: write("String"); return; - case 128: + case 129: write("Number"); return; - case 131: + case 132: write("Symbol"); return; - case 152: + case 153: emitSerializedTypeReferenceNode(node); return; - case 155: case 156: - case 159: + case 157: case 160: + case 161: case 117: - case 162: + case 163: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -30673,8 +31561,8 @@ var ts; } function emitSerializedParameterTypesOfNode(node) { if (node) { - var valueDeclaration; - if (node.kind === 217) { + var valueDeclaration = void 0; + if (node.kind === 218) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -30690,10 +31578,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 157) { + if (parameterType.kind === 158) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 152 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 153 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -30765,7 +31653,7 @@ var ts; } if (!shouldHoistDeclarationInSystemJsModule(node)) { var isES6ExportedEnum = isES6ExportedDeclaration(node); - if (!(node.flags & 2) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220))) { + if (!(node.flags & 1) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221))) { emitStart(node); if (isES6ExportedEnum) { write("export "); @@ -30794,7 +31682,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 2 && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { writeLine(); emitStart(node); write("var "); @@ -30804,8 +31692,8 @@ var ts; emitEnd(node); write(";"); } - if (modulekind !== 5 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 2)) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile) { + if (modulekind === ts.ModuleKind.System && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -30845,7 +31733,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 221) { + if (moduleDeclaration.body.kind === 222) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -30868,7 +31756,7 @@ var ts; var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { var isES6ExportedNamespace = isES6ExportedDeclaration(node); - if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221)) { + if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 222)) { emitStart(node); if (isES6ExportedNamespace) { write("export "); @@ -30886,7 +31774,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 222) { + if (node.body.kind === 223) { var saveConvertedLoopState = convertedLoopState; var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -30911,7 +31799,7 @@ var ts; emitToken(16, moduleBlock.statements.end); } write(")("); - if ((node.flags & 2) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -30921,7 +31809,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 2)) { + if (modulekind === ts.ModuleKind.System && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -30957,16 +31845,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 224) { + if (node.kind === 225) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 227) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 228) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 225 && node.importClause && !!node.importClause.name; + return node.kind === 226 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -30975,7 +31863,7 @@ var ts; ts.forEachChild(node, emitExportImportAssignments); } function emitImportDeclaration(node) { - if (modulekind !== 5) { + if (modulekind !== ts.ModuleKind.ES6) { return emitExternalImportDeclaration(node); } if (node.importClause) { @@ -30993,7 +31881,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 227) { + if (node.importClause.namedBindings.kind === 228) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -31019,21 +31907,24 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 224 && (node.flags & 2) !== 0; + var isExportedImport = node.kind === 225 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (modulekind !== 2) { + var varOrConst = (languageVersion <= 1) ? "var " : "const "; + if (modulekind !== ts.ModuleKind.AMD) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { - if (!isExportedImport) - write("var "); + if (!isExportedImport) { + write(varOrConst); + } + ; emitModuleMemberName(namespaceDeclaration); write(" = "); } else { - var isNakedImport = 225 && !node.importClause; + var isNakedImport = 226 && !node.importClause; if (!isNakedImport) { - write("var "); + write(varOrConst); write(getGeneratedNameForNode(node)); write(" = "); } @@ -31058,7 +31949,7 @@ var ts; write(";"); } else if (namespaceDeclaration && isDefaultImport(node)) { - write("var "); + write(varOrConst); emitModuleMemberName(namespaceDeclaration); write(" = "); write(getGeneratedNameForNode(node)); @@ -31085,7 +31976,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 2)) { + else if (!(node.flags & 1)) { write("var "); } } @@ -31107,13 +31998,13 @@ var ts; } } function emitExportDeclaration(node) { - ts.Debug.assert(modulekind !== 4); - if (modulekind !== 5) { + ts.Debug.assert(modulekind !== ts.ModuleKind.System); + if (modulekind !== ts.ModuleKind.ES6) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); var generatedName = getGeneratedNameForNode(node); if (node.exportClause) { - if (modulekind !== 2) { + if (modulekind !== ts.ModuleKind.AMD) { write("var "); write(generatedName); write(" = "); @@ -31141,7 +32032,7 @@ var ts; if (hasExportStarsToExportValues && resolver.moduleExportsSomeValue(node.moduleSpecifier)) { writeLine(); write("__export("); - if (modulekind !== 2) { + if (modulekind !== ts.ModuleKind.AMD) { emitRequire(ts.getExternalModuleName(node)); } else { @@ -31173,7 +32064,7 @@ var ts; } } function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(modulekind === 5); + ts.Debug.assert(modulekind === ts.ModuleKind.ES6); var needsComma = false; for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { var specifier = specifiers_1[_a]; @@ -31192,14 +32083,14 @@ var ts; } function emitExportAssignment(node) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (modulekind === 5) { + if (modulekind === ts.ModuleKind.ES6) { writeLine(); emitStart(node); write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 216 && - expression.kind !== 217) { + if (expression.kind !== 217 && + expression.kind !== 218) { write(";"); } emitEnd(node); @@ -31207,7 +32098,7 @@ var ts; else { writeLine(); emitStart(node); - if (modulekind === 4) { + if (modulekind === ts.ModuleKind.System) { write(exportFunctionForFile + "(\"default\","); emit(node.expression); write(")"); @@ -31236,18 +32127,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 225: + case 226: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 224: - if (node.moduleReference.kind === 235 && resolver.isReferencedAliasDeclaration(node)) { + case 225: + if (node.moduleReference.kind === 236 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 231: + case 232: if (node.moduleSpecifier) { if (!node.exportClause) { if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { @@ -31267,7 +32158,7 @@ var ts; } } break; - case 230: + case 231: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -31292,10 +32183,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name); } - if (node.kind === 225 && node.importClause) { + if (node.kind === 226 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 231 && node.moduleSpecifier) { + if (node.kind === 232 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -31320,8 +32211,8 @@ var ts; var started = false; for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { var importNode = externalImports_1[_a]; - var skipNode = importNode.kind === 231 || - (importNode.kind === 225 && !importNode.importClause); + var skipNode = importNode.kind === 232 || + (importNode.kind === 226 && !importNode.importClause); if (skipNode) { continue; } @@ -31346,7 +32237,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { var externalImport = externalImports_2[_a]; - if (externalImport.kind === 231 && externalImport.exportClause) { + if (externalImport.kind === 232 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -31375,7 +32266,7 @@ var ts; } for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { var externalImport = externalImports_3[_d]; - if (externalImport.kind !== 231) { + if (externalImport.kind !== 232) { continue; } var exportDecl = externalImport; @@ -31464,14 +32355,14 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 217 || local.kind === 221 || local.kind === 220) { + if (local.kind === 218 || local.kind === 222 || local.kind === 221) { emitDeclarationName(local); } else { emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); - if (flags & 2) { + if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -31485,7 +32376,7 @@ var ts; var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 2) { + if (f.flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -31495,24 +32386,24 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 4) { + if (node.flags & 2) { return; } - if (node.kind === 216) { + if (node.kind === 217) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 217) { + if (node.kind === 218) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 220) { + if (node.kind === 221) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -31521,7 +32412,7 @@ var ts; } return; } - if (node.kind === 221) { + if (node.kind === 222) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -31530,7 +32421,7 @@ var ts; } return; } - if (node.kind === 214 || node.kind === 166) { + if (node.kind === 215 || node.kind === 167) { if (shouldHoistVariable(node, false)) { var name_30 = node.name; if (name_30.kind === 69) { @@ -31565,11 +32456,11 @@ var ts; if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { return false; } - return (ts.getCombinedNodeFlags(node) & 24576) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 251; + return (ts.getCombinedNodeFlags(node) & 3072) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 252; } function isCurrentFileSystemExternalModule() { - return modulekind === 4 && isCurrentFileExternalModule; + return modulekind === ts.ModuleKind.System && isCurrentFileExternalModule; } function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); @@ -31604,17 +32495,17 @@ var ts; var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 225: + case 226: if (!entry.importClause) { break; } - case 224: + case 225: ts.Debug.assert(importVariableName !== ""); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 231: + case 232: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { writeLine(); @@ -31658,10 +32549,10 @@ var ts; for (var i = startIndex; i < node.statements.length; i++) { var statement = node.statements[i]; switch (statement.kind) { - case 216: - case 225: + case 217: + case 226: continue; - case 231: + case 232: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -31669,7 +32560,7 @@ var ts; } } continue; - case 224: + case 225: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { continue; } @@ -31692,6 +32583,7 @@ var ts; collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); + contextObjectForFile = makeUniqueName("context"); writeLine(); write("System.register("); writeModuleName(node, emitRelativePathAsModuleName); @@ -31700,13 +32592,17 @@ var ts; var dependencyGroups = []; for (var i = 0; i < externalImports.length; i++) { var text = getExternalModuleNameText(externalImports[i], emitRelativePathAsModuleName); - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; + if (text === undefined) { + continue; + } + var key = text.substr(1, text.length - 2); + if (ts.hasProperty(groupIndices, key)) { + var groupIndex = groupIndices[key]; dependencyGroups[groupIndex].push(externalImports[i]); continue; } else { - groupIndices[text] = dependencyGroups.length; + groupIndices[key] = dependencyGroups.length; dependencyGroups.push([externalImports[i]]); } if (i !== 0) { @@ -31714,10 +32610,13 @@ var ts; } write(text); } - write("], function(" + exportFunctionForFile + ") {"); + write("], function(" + exportFunctionForFile + ", " + contextObjectForFile + ") {"); writeLine(); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true, true); + var startIndex = emitDirectivePrologues(node.statements, true, !compilerOptions.noImplicitUseStrict); + writeLine(); + write("var __moduleName = " + contextObjectForFile + " && " + contextObjectForFile + ".id;"); + writeLine(); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -31789,7 +32688,7 @@ var ts; writeModuleName(node, emitRelativePathAsModuleName); emitAMDDependencies(node, true, emitRelativePathAsModuleName); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true, true); + var startIndex = emitDirectivePrologues(node.statements, true, !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -31800,7 +32699,7 @@ var ts; write("});"); } function emitCommonJSModule(node) { - var startIndex = emitDirectivePrologues(node.statements, false, true); + var startIndex = emitDirectivePrologues(node.statements, false, !compilerOptions.noImplicitUseStrict); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -31819,7 +32718,7 @@ var ts; writeLines(" }\n})("); emitAMDFactoryHeader(dependencyNames); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, true, true); + var startIndex = emitDirectivePrologues(node.statements, true, !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -31899,6 +32798,16 @@ var ts; } return result; } + function isJsxChildEmittable(child) { + if (child.kind === 244) { + return !!child.expression; + } + else if (child.kind === 240) { + return !!getTextToEmit(child); + } + return true; + } + ; function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2: @@ -31985,22 +32894,22 @@ var ts; } function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { - if ((languageVersion < 2) && (!extendsEmitted && node.flags & 4194304)) { + if ((languageVersion < 2) && (!extendsEmitted && node.flags & 262144)) { writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && node.flags & 8388608) { + if (!decorateEmitted && node.flags & 524288) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && node.flags & 16777216) { + if (!paramEmitted && node.flags & 1048576) { writeLines(paramHelper); paramEmitted = true; } - if (!awaiterEmitted && node.flags & 33554432) { + if (!awaiterEmitted && node.flags & 2097152) { writeLines(awaiterHelper); awaiterEmitted = true; } @@ -32012,7 +32921,7 @@ var ts; emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (isOwnFileEmit || (!ts.isExternalModule(node) && compilerOptions.isolatedModules)) { - var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ts.ModuleKind.CommonJS]; emitModule(node); } else { @@ -32040,7 +32949,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 4) { + if (node.flags & 2) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -32083,28 +32992,28 @@ var ts; } function isSpecializedCommentHandling(node) { switch (node.kind) { - case 218: - case 216: - case 225: - case 224: case 219: - case 230: + case 217: + case 226: + case 225: + case 220: + case 231: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 196: + case 197: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 221: + case 222: return shouldEmitModuleDeclaration(node); - case 220: + case 221: return shouldEmitEnumDeclaration(node); } ts.Debug.assert(!isSpecializedCommentHandling(node)); - if (node.kind !== 195 && + if (node.kind !== 196 && node.parent && - node.parent.kind === 177 && + node.parent.kind === 178 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -32115,13 +33024,13 @@ var ts; switch (node.kind) { case 69: return emitIdentifier(node); - case 139: + case 140: return emitParameter(node); + case 145: case 144: - case 143: return emitMethod(node); - case 146: case 147: + case 148: return emitAccessor(node); case 97: return emitThis(node); @@ -32141,142 +33050,142 @@ var ts; case 13: case 14: return emitLiteral(node); - case 186: - return emitTemplateExpression(node); - case 193: - return emitTemplateSpan(node); - case 236: - case 237: - return emitJsxElement(node); - case 239: - return emitJsxText(node); - case 243: - return emitJsxExpression(node); - case 136: - return emitQualifiedName(node); - case 164: - return emitObjectBindingPattern(node); - case 165: - return emitArrayBindingPattern(node); - case 166: - return emitBindingElement(node); - case 167: - return emitArrayLiteral(node); - case 168: - return emitObjectLiteral(node); - case 248: - return emitPropertyAssignment(node); - case 249: - return emitShorthandPropertyAssignment(node); - case 137: - return emitComputedPropertyName(node); - case 169: - return emitPropertyAccess(node); - case 170: - return emitIndexedAccess(node); - case 171: - return emitCallExpression(node); - case 172: - return emitNewExpression(node); - case 173: - return emitTaggedTemplateExpression(node); - case 174: - return emit(node.expression); - case 192: - return emit(node.expression); - case 175: - return emitParenExpression(node); - case 216: - case 176: - case 177: - return emitFunctionDeclaration(node); - case 178: - return emitDeleteExpression(node); - case 179: - return emitTypeOfExpression(node); - case 180: - return emitVoidExpression(node); - case 181: - return emitAwaitExpression(node); - case 182: - return emitPrefixUnaryExpression(node); - case 183: - return emitPostfixUnaryExpression(node); - case 184: - return emitBinaryExpression(node); - case 185: - return emitConditionalExpression(node); - case 188: - return emitSpreadElementExpression(node); case 187: - return emitYieldExpression(node); - case 190: - return; - case 195: - case 222: - return emitBlock(node); - case 196: - return emitVariableStatement(node); - case 197: - return write(";"); - case 198: - return emitExpressionStatement(node); - case 199: - return emitIfStatement(node); - case 200: - return emitDoStatement(node); - case 201: - return emitWhileStatement(node); - case 202: - return emitForStatement(node); - case 204: - case 203: - return emitForInOrForOfStatement(node); - case 205: - case 206: - return emitBreakOrContinueStatement(node); - case 207: - return emitReturnStatement(node); - case 208: - return emitWithStatement(node); - case 209: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 194: + return emitTemplateSpan(node); + case 237: + case 238: + return emitJsxElement(node); + case 240: + return emitJsxText(node); case 244: - case 245: - return emitCaseOrDefaultClause(node); - case 210: - return emitLabeledStatement(node); - case 211: - return emitThrowStatement(node); - case 212: - return emitTryStatement(node); - case 247: - return emitCatchClause(node); - case 213: - return emitDebuggerStatement(node); - case 214: - return emitVariableDeclaration(node); - case 189: - return emitClassExpression(node); - case 217: - return emitClassDeclaration(node); - case 218: - return emitInterfaceDeclaration(node); - case 220: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 137: + return emitQualifiedName(node); + case 165: + return emitObjectBindingPattern(node); + case 166: + return emitArrayBindingPattern(node); + case 167: + return emitBindingElement(node); + case 168: + return emitArrayLiteral(node); + case 169: + return emitObjectLiteral(node); + case 249: + return emitPropertyAssignment(node); case 250: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 138: + return emitComputedPropertyName(node); + case 170: + return emitPropertyAccess(node); + case 171: + return emitIndexedAccess(node); + case 172: + return emitCallExpression(node); + case 173: + return emitNewExpression(node); + case 174: + return emitTaggedTemplateExpression(node); + case 175: + return emit(node.expression); + case 193: + return emit(node.expression); + case 176: + return emitParenExpression(node); + case 217: + case 177: + case 178: + return emitFunctionDeclaration(node); + case 179: + return emitDeleteExpression(node); + case 180: + return emitTypeOfExpression(node); + case 181: + return emitVoidExpression(node); + case 182: + return emitAwaitExpression(node); + case 183: + return emitPrefixUnaryExpression(node); + case 184: + return emitPostfixUnaryExpression(node); + case 185: + return emitBinaryExpression(node); + case 186: + return emitConditionalExpression(node); + case 189: + return emitSpreadElementExpression(node); + case 188: + return emitYieldExpression(node); + case 191: + return; + case 196: + case 223: + return emitBlock(node); + case 197: + return emitVariableStatement(node); + case 198: + return write(";"); + case 199: + return emitExpressionStatement(node); + case 200: + return emitIfStatement(node); + case 201: + return emitDoStatement(node); + case 202: + return emitWhileStatement(node); + case 203: + return emitForStatement(node); + case 205: + case 204: + return emitForInOrForOfStatement(node); + case 206: + case 207: + return emitBreakOrContinueStatement(node); + case 208: + return emitReturnStatement(node); + case 209: + return emitWithStatement(node); + case 210: + return emitSwitchStatement(node); + case 245: + case 246: + return emitCaseOrDefaultClause(node); + case 211: + return emitLabeledStatement(node); + case 212: + return emitThrowStatement(node); + case 213: + return emitTryStatement(node); + case 248: + return emitCatchClause(node); + case 214: + return emitDebuggerStatement(node); + case 215: + return emitVariableDeclaration(node); + case 190: + return emitClassExpression(node); + case 218: + return emitClassDeclaration(node); + case 219: + return emitInterfaceDeclaration(node); case 221: - return emitModuleDeclaration(node); - case 225: - return emitImportDeclaration(node); - case 224: - return emitImportEqualsDeclaration(node); - case 231: - return emitExportDeclaration(node); - case 230: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 251: + return emitEnumMember(node); + case 222: + return emitModuleDeclaration(node); + case 226: + return emitImportDeclaration(node); + case 225: + return emitImportEqualsDeclaration(node); + case 232: + return emitExportDeclaration(node); + case 231: + return emitExportAssignment(node); + case 252: return emitSourceFileNode(node); } } @@ -32306,7 +33215,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 251 || node.pos !== node.parent.pos) { + if (node.parent.kind === 252 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -32318,7 +33227,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 251 || node.end !== node.parent.end) { + if (node.parent.kind === 252 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentText, node.end); } } @@ -32420,7 +33329,7 @@ var ts; ts.ioReadTime = 0; ts.ioWriteTime = 0; var emptyArray = []; - ts.version = "1.8.0"; + ts.version = "1.9.0"; function findConfigFile(searchPath, fileExists) { var fileName = "tsconfig.json"; while (true) { @@ -32443,94 +33352,331 @@ var ts; 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, compilerOptions, host); - case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + function trace(host, message) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceModuleResolution && host.trace !== undefined; + } + function startsWith(str, prefix) { + return str.lastIndexOf(prefix, 0) === 0; + } + function endsWith(str, suffix) { + var expectedPos = str.length - suffix.length; + return str.indexOf(suffix, expectedPos) === expectedPos; + } + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + return false; + } + } } + return true; + } + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + } + function moduleHasNonRelativeName(moduleName) { + if (ts.isRootedDiskPath(moduleName)) { + return false; + } + var i = moduleName.lastIndexOf("./", 1); + var startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === 46); + return !startsWithDotSlashOrDotDotSlash; + } + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; } ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } + } + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var longestMatchPrefixLength = -1; + var matchedPattern; + var matchedStar; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + for (var key in state.compilerOptions.paths) { + var pattern = key; + var indexOfStar = pattern.indexOf("*"); + if (indexOfStar !== -1) { + var prefix = pattern.substr(0, indexOfStar); + var suffix = pattern.substr(indexOfStar + 1); + if (moduleName.length >= prefix.length + suffix.length && + startsWith(moduleName, prefix) && + endsWith(moduleName, suffix)) { + if (prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = prefix.length; + matchedPattern = pattern; + matchedStar = moduleName.substr(prefix.length, moduleName.length - suffix.length); + } + } + } + else if (pattern === moduleName) { + matchedPattern = pattern; + matchedStar = undefined; + break; + } + } + } + if (matchedPattern) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPattern); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPattern]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("\*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { - var failedLookupLocations = []; - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(supportedExtensions, candidate, failedLookupLocations, false, host); - if (resolvedFileName) { - return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, false, failedLookupLocations); + } + var isExternalLibraryImport = false; + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, false, host); - return resolvedFileName - ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state); + isExternalLibraryImport = resolvedFileName !== undefined; } else { - return loadModuleFromNodeModules(moduleName, containingDirectory, host); + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; - function loadNodeModuleFromFile(extensions, candidate, failedLookupLocation, onlyRecordFailures, host) { + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { return ts.forEach(extensions, tryLoad); function tryLoad(ext) { + if (ext === ".tsx" && state.skipTsx) { + return undefined; + } var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (!onlyRecordFailures && host.fileExists(fileName)) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_module_resolution_result, fileName); + } return fileName; } else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } failedLookupLocation.push(fileName); return undefined; } } } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, host) { + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, host); - if (directoryExists && host.fileExists(packageJsonPath)) { - var jsonContent; + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var jsonContent = void 0; try { - var jsonText = host.readFile(packageJsonPath); + var jsonText = state.host.readFile(packageJsonPath); jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; } catch (e) { jsonContent = { typings: undefined }; } - if (typeof jsonContent.typings === "string") { - var path = ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)); - var result = loadNodeModuleFromFile(extensions, path, failedLookupLocation, !directoryProbablyExists(ts.getDirectoryPath(path), host), host); - if (result) { - return result; + if (jsonContent.typings) { + if (typeof jsonContent.typings === "string") { + var typingsFile = ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_typings_field_0_that_references_1, jsonContent.typings, typingsFile); + } + var result = loadModuleFromFile(typingsFile, extensions, failedLookupLocation, !directoryProbablyExists(ts.getDirectoryPath(typingsFile), state.host), state); + if (result) { + return result; + } + } + else if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_typings_field_in_package_json_to_be_string_got_0, typeof jsonContent.typings); + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_typings_field); } } } else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, host); + return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); } - function loadModuleFromNodeModules(moduleName, directory, host) { - var failedLookupLocations = []; + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state) { directory = ts.normalizeSlashes(directory); while (true) { var baseName = ts.getBaseFileName(directory); if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, host); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var result = loadNodeModuleFromFile(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host); + var result = loadModuleFromFile(candidate, ts.supportedTypeScriptExtensions, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + return result; } - result = loadNodeModuleFromDirectory(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host); + result = loadNodeModuleFromDirectory(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + return result; } } var parentPath = ts.getDirectoryPath(directory); @@ -32539,43 +33685,36 @@ var ts; } directory = parentPath; } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - function nameStartsWithDotSlashOrDotDotSlash(name) { - var i = name.lastIndexOf("./", 1); - return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + return undefined; } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - if (moduleName.indexOf("!") != -1) { - return { resolvedModule: undefined, failedLookupLocations: [] }; - } - var searchPath = ts.getDirectoryPath(containingFile); - var searchName; + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; var failedLookupLocations = []; - var referencedSourceFile; var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(supportedExtensions, function (extension) { - if (extension === ".tsx" && !compilerOptions.jsx) { - return undefined; + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, false, failedLookupLocations); + } + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + if (referencedSourceFile) { + break; } - var candidate = searchName + extension; - if (host.fileExists(candidate)) { - return candidate; + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + break; } - else { - failedLookupLocations.push(candidate); - } - }); - if (referencedSourceFile) { - break; + containingDirectory = parentPath; } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); } return referencedSourceFile ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } @@ -32583,7 +33722,7 @@ var ts; } ts.classicNameResolver = classicNameResolver; ts.defaultInitCompilerOptions = { - module: 1, + module: ts.ModuleKind.CommonJS, target: 1, noImplicitAny: false, sourceMap: false @@ -32652,6 +33791,7 @@ var ts; getNewLine: function () { return newLine; }, fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, readFile: function (fileName) { return ts.sys.readFile(fileName); }, + trace: function (s) { return ts.sys.write(s + newLine); }, directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); } }; } @@ -32888,10 +34028,17 @@ var ts; return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + var declarationDiagnostics = []; + if (options.noEmit) { + return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true }; + } if (options.noEmitOnError) { - var preEmitDiagnostics = getPreEmitDiagnostics(program, undefined, cancellationToken); - if (preEmitDiagnostics.length > 0) { - return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true }; + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (diagnostics.length === 0 && program.getCompilerOptions().declaration) { + declarationDiagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken); + } + if (diagnostics.length > 0 || declarationDiagnostics.length > 0) { + return { diagnostics: diagnostics, sourceMaps: undefined, emitSkipped: true }; } } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); @@ -32963,44 +34110,47 @@ var ts; return false; } switch (node.kind) { - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 230: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - case 217: + case 231: + if (node.isExportEquals) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 218: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 246: + case 247: var heritageClause = node; if (heritageClause.token === 106) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 218: + case 219: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 221: + case 222: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 219: + case 220: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 144: - case 143: case 145: + case 144: case 146: case 147: - case 176: - case 216: + case 148: case 177: - case 216: + case 217: + case 178: + case 217: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -33008,20 +34158,20 @@ var ts; return true; } break; - case 196: + case 197: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 214: + case 215: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 171: case 172: + case 173: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start_2 = expression.typeArguments.pos; @@ -33029,7 +34179,7 @@ var ts; return true; } break; - case 139: + case 140: var parameter = node; if (parameter.modifiers) { var start_3 = parameter.modifiers.pos; @@ -33045,18 +34195,20 @@ var ts; return true; } break; - case 142: + case 143: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 220: + case 221: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 174: + case 175: 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 140: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); + case 141: + if (!options.experimentalDecorators) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + } return true; } return ts.forEachChild(node, walk); @@ -33084,6 +34236,7 @@ var ts; case 112: case 110: case 111: + case 127: case 122: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; @@ -33154,9 +34307,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 226: case 225: - case 224: - case 231: + case 232: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -33168,8 +34321,8 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 221: - if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 4 || ts.isDeclarationFile(file))) { + case 222: + if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 2 || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); @@ -33184,7 +34337,7 @@ var ts; } } function collectRequireCalls(node) { - if (ts.isRequireCall(node)) { + if (ts.isRequireCall(node, true)) { (imports || (imports = [])).push(node.arguments[0]); } else { @@ -33307,7 +34460,7 @@ var ts; if (shouldAddFile) { var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { - if (!ts.isExternalModule(importedFile)) { + if (!ts.isExternalModule(importedFile) && importedFile.statements.length) { var start_5 = ts.getTokenPosOfNode(file.imports[i], file); fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_5, file.imports[i].end - start_5, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); } @@ -33397,6 +34550,25 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } } + if (options.paths && options.baseUrl === undefined) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option)); + } + if (options.paths) { + for (var key in options.paths) { + if (!ts.hasProperty(options.paths, key)) { + continue; + } + if (!hasZeroOrOneAsteriskCharacter(key)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); + } + for (var _i = 0, _a = options.paths[key]; _i < _a.length; _i++) { + var subst = _a[_i]; + if (!hasZeroOrOneAsteriskCharacter(subst)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); + } + } + } + } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); @@ -33420,7 +34592,7 @@ var ts; 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) { + if (options.module === ts.ModuleKind.None && languageVersion < 2) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -33429,14 +34601,14 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { + else if (firstExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) { var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); } - if (options.module === 5 && languageVersion < 2) { + if (options.module === ts.ModuleKind.ES6 && languageVersion < 2) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); } - if (outFile && options.module && !(options.module === 2 || options.module === 4)) { + if (outFile && options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); } if (options.outDir || @@ -33469,14 +34641,14 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.reactNamespace && !ts.isIdentifier(options.reactNamespace, languageVersion)) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); } - if (!options.noEmit) { + if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); - var emitFilesSeen = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); + var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { - verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen); - verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen); + verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); + verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); } function verifyEmitFilePath(emitFileName, emitFilesSeen) { @@ -33506,7 +34678,7 @@ var ts; var BreakpointResolver; (function (BreakpointResolver) { function spanInSourceFileAtLocation(sourceFile, position) { - if (sourceFile.flags & 4096) { + if (sourceFile.isDeclarationFile) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -33548,89 +34720,89 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 196: + case 197: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 214: - case 142: - case 141: - return spanInVariableDeclaration(node); - case 139: - return spanInParameterDeclaration(node); - case 216: - case 144: + case 215: case 143: - case 146: - case 147: + case 142: + return spanInVariableDeclaration(node); + case 140: + return spanInParameterDeclaration(node); + case 217: case 145: - case 176: + case 144: + case 147: + case 148: + case 146: case 177: + case 178: return spanInFunctionDeclaration(node); - case 195: + case 196: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 222: + case 223: return spanInBlock(node); - case 247: + case 248: return spanInBlock(node.block); - case 198: - return textSpan(node.expression); - case 207: - return textSpan(node.getChildAt(0), node.expression); - case 201: - return textSpanEndingAtNextToken(node, node.expression); - case 200: - return spanInNode(node.statement); - case 213: - return textSpan(node.getChildAt(0)); case 199: - return textSpanEndingAtNextToken(node, node.expression); - case 210: - return spanInNode(node.statement); - case 206: - case 205: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 208: + return textSpan(node.getChildAt(0), node.expression); case 202: - return spanInForStatement(node); - case 203: return textSpanEndingAtNextToken(node, node.expression); - case 204: - return spanInInitializerOfForLike(node); - case 209: + case 201: + return spanInNode(node.statement); + case 214: + return textSpan(node.getChildAt(0)); + case 200: return textSpanEndingAtNextToken(node, node.expression); - case 244: - case 245: - return spanInNode(node.statements[0]); - case 212: - return spanInBlock(node.tryBlock); case 211: + return spanInNode(node.statement); + case 207: + case 206: + return textSpan(node.getChildAt(0), node.label); + case 203: + return spanInForStatement(node); + case 204: + return textSpanEndingAtNextToken(node, node.expression); + case 205: + return spanInInitializerOfForLike(node); + case 210: + return textSpanEndingAtNextToken(node, node.expression); + case 245: + case 246: + return spanInNode(node.statements[0]); + case 213: + return spanInBlock(node.tryBlock); + case 212: return textSpan(node, node.expression); - case 230: - return textSpan(node, node.expression); - case 224: - return textSpan(node, node.moduleReference); - case 225: - return textSpan(node, node.moduleSpecifier); case 231: + return textSpan(node, node.expression); + case 225: + return textSpan(node, node.moduleReference); + case 226: return textSpan(node, node.moduleSpecifier); - case 221: + case 232: + return textSpan(node, node.moduleSpecifier); + case 222: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 217: - case 220: - case 250: - case 166: - return textSpan(node); - case 208: - return spanInNode(node.statement); - case 140: - return spanInNodeArray(node.parent.decorators); - case 164: - case 165: - return spanInBindingPattern(node); case 218: + case 221: + case 251: + case 167: + return textSpan(node); + case 209: + return spanInNode(node.statement); + case 141: + return spanInNodeArray(node.parent.decorators); + case 165: + case 166: + return spanInBindingPattern(node); case 219: + case 220: return undefined; case 23: case 1: @@ -33658,20 +34830,20 @@ var ts; case 72: case 85: return spanInNextNode(node); - case 135: + case 136: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } if ((node.kind === 69 || - node.kind == 188 || - node.kind === 248 || - node.kind === 249) && + node.kind == 189 || + node.kind === 249 || + node.kind === 250) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 184) { + if (node.kind === 185) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); @@ -33686,38 +34858,38 @@ var ts; } if (ts.isExpression(node)) { switch (node.parent.kind) { - case 200: + case 201: return spanInPreviousNode(node); - case 140: + case 141: return spanInNode(node.parent); - case 202: - case 204: + case 203: + case 205: return textSpan(node); - case 184: + case 185: if (node.parent.operatorToken.kind === 24) { return textSpan(node); } break; - case 177: + case 178: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 248 && + if (node.parent.kind === 249 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 174 && node.parent.type === node) { + if (node.parent.kind === 175 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 214 || - node.parent.kind === 139)) { + if ((node.parent.kind === 215 || + node.parent.kind === 140)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -33725,7 +34897,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 184) { + if (node.parent.kind === 185) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -33746,15 +34918,15 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 203) { + if (variableDeclaration.parent.parent.kind === 204) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { return spanInBindingPattern(variableDeclaration.name); } if (variableDeclaration.initializer || - (variableDeclaration.flags & 2) || - variableDeclaration.parent.parent.kind === 204) { + (variableDeclaration.flags & 1) || + variableDeclaration.parent.parent.kind === 205) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -33764,7 +34936,7 @@ var ts; } function canHaveSpanInParameterDeclaration(parameter) { return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 8) || !!(parameter.flags & 16); + !!(parameter.flags & 4) || !!(parameter.flags & 8); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -33785,8 +34957,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 2) || - (functionDeclaration.parent.kind === 217 && functionDeclaration.kind !== 145); + return !!(functionDeclaration.flags & 1) || + (functionDeclaration.parent.kind === 218 && functionDeclaration.kind !== 146); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -33806,22 +34978,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 221: + case 222: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 201: - case 199: - case 203: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 202: + case 200: case 204: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 203: + case 205: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStaement) { - if (forLikeStaement.initializer.kind === 215) { + if (forLikeStaement.initializer.kind === 216) { var variableDeclarationList = forLikeStaement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -33843,62 +35015,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 190 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 191 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 166) { + if (bindingPattern.parent.kind === 167) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 165 && node.kind !== 164); - var elements = node.kind === 167 ? + ts.Debug.assert(node.kind !== 166 && node.kind !== 165); + var elements = node.kind === 168 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 190 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 191 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 184 ? node.parent : node); + return textSpan(node.parent.kind === 185 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 220: + case 221: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 217: + case 218: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 223: + case 224: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 222: + case 223: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 220: - case 217: + case 221: + case 218: return textSpan(node); - case 195: + case 196: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 247: + case 248: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 223: + case 224: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 164: + case 165: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -33911,7 +35083,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 165: + case 166: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -33923,33 +35095,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 200 || - node.parent.kind === 171 || - node.parent.kind === 172) { + if (node.parent.kind === 201 || + node.parent.kind === 172 || + node.parent.kind === 173) { return spanInPreviousNode(node); } - if (node.parent.kind === 175) { + if (node.parent.kind === 176) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 176: - case 216: case 177: - case 144: - case 143: - case 146: - case 147: + case 217: + case 178: case 145: - case 201: - case 200: + case 144: + case 147: + case 148: + case 146: case 202: - case 204: - case 171: + case 201: + case 203: + case 205: case 172: - case 175: + case 173: + case 176: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -33957,26 +35129,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 248 || - node.parent.kind === 139) { + node.parent.kind === 249 || + node.parent.kind === 140) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 174) { + if (node.parent.kind === 175) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 200) { + if (node.parent.kind === 201) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 204) { + if (node.parent.kind === 205) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -34054,7 +35226,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 177; + return ts.isFunctionBlock(node) && node.parent.kind !== 178; } var depth = 0; var maxDepth = 20; @@ -34066,26 +35238,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 195: + case 196: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; + var parent_9 = n.parent; var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_8.kind === 200 || - parent_8.kind === 203 || - parent_8.kind === 204 || - parent_8.kind === 202 || - parent_8.kind === 199 || - parent_8.kind === 201 || - parent_8.kind === 208 || - parent_8.kind === 247) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + if (parent_9.kind === 201 || + parent_9.kind === 204 || + parent_9.kind === 205 || + parent_9.kind === 203 || + parent_9.kind === 200 || + parent_9.kind === 202 || + parent_9.kind === 209 || + parent_9.kind === 248) { + addOutliningSpan(parent_9, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 212) { - var tryStatement = parent_8; + if (parent_9.kind === 213) { + var tryStatement = parent_9; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_9, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -34105,23 +35277,23 @@ var ts; }); break; } - case 222: { + case 223: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 217: case 218: - case 220: - case 168: - case 223: { + case 219: + case 221: + case 169: + case 224: { var openBrace = ts.findChildOfKind(n, 15, sourceFile); var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 167: + case 168: var openBracket = ts.findChildOfKind(n, 19, sourceFile); var closeBracket = ts.findChildOfKind(n, 20, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -34155,8 +35327,8 @@ var ts; if (!matches) { continue; } - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { @@ -34206,7 +35378,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 137) { + else if (declaration.name.kind === 138) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -34223,7 +35395,7 @@ var ts; } return true; } - if (expression.kind === 169) { + if (expression.kind === 170) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -34234,7 +35406,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 137) { + if (declaration.name.kind === 138) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -34296,14 +35468,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 221: + case 222: do { current = current.parent; - } while (current.kind === 221); - case 217: - case 220: + } while (current.kind === 222); case 218: - case 216: + case 221: + case 219: + case 217: indent++; } current = current.parent; @@ -34314,26 +35486,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 196: + case 197: ts.forEach(node.declarationList.declarations, visit); break; - case 164: case 165: + case 166: ts.forEach(node.elements, visit); break; - case 231: + case 232: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 225: + case 226: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227) { + if (importClause.namedBindings.kind === 228) { childNodes.push(importClause.namedBindings); } else { @@ -34342,20 +35514,20 @@ var ts; } } break; - case 166: - case 214: + case 167: + case 215: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 217: - case 220: case 218: case 221: - case 216: - case 224: - case 229: - case 233: + case 219: + case 222: + case 217: + case 225: + case 230: + case 234: childNodes.push(node); break; } @@ -34390,17 +35562,17 @@ var ts; for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; switch (node.kind) { - case 217: - case 220: case 218: + case 221: + case 219: topLevelNodes.push(node); break; - case 221: + case 222: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 216: + case 217: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -34411,9 +35583,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 216) { - if (functionDeclaration.body && functionDeclaration.body.kind === 195) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 216 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 217) { + if (functionDeclaration.body && functionDeclaration.body.kind === 196) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 217 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -34466,42 +35638,42 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 139: + case 140: if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 1022) === 0) { + if ((node.flags & 959) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 145: case 144: - case 143: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 146: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 147: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 150: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 250: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 148: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 149: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 142: - case 141: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 151: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 251: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 216: + case 149: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 150: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 143: + case 142: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 217: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 214: - case 166: - var variableDeclarationNode; + case 215: + case 167: + var variableDeclarationNode = void 0; var name_32; - if (node.kind === 166) { + if (node.kind === 167) { name_32 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 214) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 215) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -34520,13 +35692,13 @@ var ts; else { return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.variableElement); } - case 145: + case 146: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 233: - case 229: - case 224: - case 226: + case 234: + case 230: + case 225: case 227: + case 228: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -34556,17 +35728,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 251: + case 252: return createSourceFileItem(node); - case 217: - return createClassItem(node); - case 220: - return createEnumItem(node); case 218: - return createIterfaceItem(node); + return createClassItem(node); case 221: + return createEnumItem(node); + case 219: + return createIterfaceItem(node); + case 222: return createModuleItem(node); - case 216: + case 217: return createFunctionItem(node); } return undefined; @@ -34576,7 +35748,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 221) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 222) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -34588,7 +35760,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 === 195) { + if (node.body && node.body.kind === 196) { 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)); } @@ -34609,7 +35781,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 145 && member; + return member.kind === 146 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -34630,19 +35802,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 137; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 138; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 221) { + while (node.body.kind === 222) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 251 + return node.kind === 252 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -35097,14 +36269,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 171) { + if (argumentInfo.invocation.kind !== 172) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 69 ? expression - : expression.kind === 169 + : expression.kind === 170 ? expression.name : undefined; if (!name || !name.text) { @@ -35116,8 +36288,8 @@ var ts; var nameToDeclarations = sourceFile_1.getNamedDeclarations(); var declarations = ts.getProperty(nameToDeclarations, name.text); if (declarations) { - for (var _b = 0, declarations_7 = declarations; _b < declarations_7.length; _b++) { - var declaration = declarations_7[_b]; + for (var _b = 0, declarations_8 = declarations; _b < declarations_8.length; _b++) { + var declaration = declarations_8[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -35133,7 +36305,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 171 || node.parent.kind === 172) { + if (node.parent.kind === 172 || node.parent.kind === 173) { var callExpression = node.parent; if (node.kind === 25 || node.kind === 17) { @@ -35164,23 +36336,23 @@ var ts; }; } } - else if (node.kind === 11 && node.parent.kind === 173) { + else if (node.kind === 11 && node.parent.kind === 174) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 12 && node.parent.parent.kind === 173) { + else if (node.kind === 12 && node.parent.parent.kind === 174) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 186); + ts.Debug.assert(templateExpression.kind === 187); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 193 && node.parent.parent.parent.kind === 173) { + else if (node.parent.kind === 194 && node.parent.parent.parent.kind === 174) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 186); + ts.Debug.assert(templateExpression.kind === 187); if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -35244,7 +36416,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 186) { + if (template.kind === 187) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -35253,7 +36425,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 251; n = n.parent) { + for (var n = node; n.kind !== 252; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -35433,39 +36605,39 @@ var ts; return false; } switch (n.kind) { - case 217: case 218: - case 220: - case 168: - case 164: - case 156: - case 195: - case 222: + case 219: + case 221: + case 169: + case 165: + case 157: + case 196: case 223: + case 224: return nodeEndsWith(n, 16, sourceFile); - case 247: + case 248: return isCompletedNode(n.block, sourceFile); - case 172: + case 173: if (!n.arguments) { return true; } - case 171: - case 175: - case 161: + case 172: + case 176: + case 162: return nodeEndsWith(n, 18, sourceFile); - case 153: case 154: + case 155: return isCompletedNode(n.type, sourceFile); - case 145: case 146: case 147: - case 216: - case 176: - case 144: - case 143: - case 149: case 148: + case 217: case 177: + case 145: + case 144: + case 150: + case 149: + case 178: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -35473,62 +36645,62 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 18, sourceFile); - case 221: + case 222: return n.body && isCompletedNode(n.body, sourceFile); - case 199: + case 200: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 198: + case 199: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 23); - case 167: - case 165: - case 170: - case 137: - case 158: + case 168: + case 166: + case 171: + case 138: + case 159: return nodeEndsWith(n, 20, sourceFile); - case 150: + case 151: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20, sourceFile); - case 244: case 245: + case 246: return false; - case 202: case 203: case 204: - case 201: + case 205: + case 202: return isCompletedNode(n.statement, sourceFile); - case 200: + case 201: var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 155: + case 156: return isCompletedNode(n.exprName, sourceFile); - case 179: - case 178: case 180: - case 187: + case 179: + case 181: case 188: + case 189: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 173: + case 174: return isCompletedNode(n.template, sourceFile); - case 186: + case 187: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 193: + case 194: return ts.nodeIsPresent(n.literal); - case 182: + case 183: return isCompletedNode(n.operand, sourceFile); - case 184: - return isCompletedNode(n.right, sourceFile); case 185: + return isCompletedNode(n.right, sourceFile); + case 186: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -35571,7 +36743,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 274 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 275 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -35651,7 +36823,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 239) { + if (isToken(n) || n.kind === 240) { return n; } var children = n.getChildren(); @@ -35659,16 +36831,16 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 239) { + if (isToken(n) || n.kind === 240) { return n; } var children = n.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 239)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 240)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 239 && start === child.end); + (child.kind === 240 && start === child.end); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -35678,7 +36850,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 251); + ts.Debug.assert(startNode !== undefined || n.kind === 252); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -35695,7 +36867,7 @@ var ts; ts.findPrecedingToken = findPrecedingToken; function isInString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position); - return token && (token.kind === 9 || token.kind === 163) && position > token.getStart(); + return token && (token.kind === 9 || token.kind === 164) && position > token.getStart(); } ts.isInString = isInString; function isInComment(sourceFile, position) { @@ -35760,17 +36932,17 @@ var ts; function getNodeModifiers(node) { var flags = ts.getCombinedNodeFlags(node); var result = []; - if (flags & 16) - result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 32) - result.push(ts.ScriptElementKindModifier.protectedMemberModifier); if (flags & 8) + result.push(ts.ScriptElementKindModifier.privateMemberModifier); + if (flags & 16) + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); + if (flags & 4) result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 64) + if (flags & 32) result.push(ts.ScriptElementKindModifier.staticModifier); if (flags & 128) result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 2) + if (flags & 1) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) result.push(ts.ScriptElementKindModifier.ambientModifier); @@ -35778,17 +36950,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 152 || node.kind === 171) { + if (node.kind === 153 || node.kind === 172) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 217 || node.kind === 218) { + if (ts.isFunctionLike(node) || node.kind === 218 || node.kind === 219) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 135; + return n.kind >= 0 && n.kind <= 136; } ts.isToken = isToken; function isWord(kind) { @@ -35804,7 +36976,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 - || kind === 163 + || kind === 164 || kind === 10 || ts.isTemplateLiteralKind(kind)) { return true; @@ -35848,18 +37020,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 167 || - node.kind === 168) { - if (node.parent.kind === 184 && + if (node.kind === 168 || + node.kind === 169) { + if (node.parent.kind === 185 && node.parent.left === node && node.parent.operatorToken.kind === 56) { return true; } - if (node.parent.kind === 204 && + if (node.parent.kind === 205 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 248 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 249 ? node.parent.parent : node.parent)) { return true; } } @@ -35870,7 +37042,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 139; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 140; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -36051,7 +37223,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 229 || location.parent.kind === 233) && + (location.parent.kind === 230 || location.parent.kind === 234) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -36153,10 +37325,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 242: + case 239: case 241: case 238: - case 240: - case 237: return node.kind === 69; } } @@ -36467,21 +37639,21 @@ var ts; function Rules() { 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, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, 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, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), 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.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; 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([69, 3, 73]); @@ -36490,59 +37662,59 @@ var ts; 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.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, 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, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 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, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 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, 42), 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([102, 98, 92, 78, 94, 101, 119]), 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([108, 74]), 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.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102, 98, 92, 78, 94, 101, 119]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108, 74]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87, 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(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 79, 80, 71]), 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([100, 85]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 129]), 69), 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(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 127]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 129, 113, 132]), 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([83, 106])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 79, 80, 71]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100, 85]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 130]), 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 128]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 130, 113, 133]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 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, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, 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, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, 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([115, 69, 82, 77, 73, 113, 112, 110, 111, 123, 129, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115, 69, 82, 77, 73, 113, 112, 110, 111, 123, 130, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([69, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -36596,33 +37768,33 @@ var ts; this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), 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.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), 2)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 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.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } @@ -36636,33 +37808,33 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 202; + return context.contextNode.kind === 203; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 184: case 185: - case 192: - case 151: - case 159: + case 186: + case 193: + case 152: case 160: + case 161: return true; - case 166: - case 219: - case 224: - case 214: - case 139: - case 250: + case 167: + case 220: + case 225: + case 215: + case 140: + case 251: + case 143: case 142: - case 141: return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; - case 203: - return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; case 204: - return context.currentTokenSpan.kind === 135 || context.nextTokenSpan.kind === 135; + return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; + case 205: + return context.currentTokenSpan.kind === 136 || context.nextTokenSpan.kind === 136; } return false; }; @@ -36670,7 +37842,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 185; + return context.contextNode.kind === 186; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -36695,86 +37867,86 @@ var ts; return true; } switch (node.kind) { - case 195: + case 196: + case 224: + case 169: case 223: - case 168: - case 222: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 216: + case 217: + case 145: case 144: - case 143: - case 146: case 147: case 148: - case 176: - case 145: + case 149: case 177: - case 218: + case 146: + case 178: + case 219: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 216 || context.contextNode.kind === 176; + return context.contextNode.kind === 217 || context.contextNode.kind === 177; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 217: - case 189: case 218: - case 220: - case 156: + case 190: + case 219: case 221: + case 157: + case 222: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 217: - case 221: - case 220: - case 195: - case 247: + case 218: case 222: - case 209: + case 221: + case 196: + case 248: + case 223: + case 210: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 199: - case 209: - case 202: + case 200: + case 210: case 203: case 204: + case 205: + case 202: + case 213: case 201: - case 212: - case 200: - case 208: - case 247: + case 209: + case 248: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 168; + return context.contextNode.kind === 169; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 171; + return context.contextNode.kind === 172; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 172; + return context.contextNode.kind === 173; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -36786,10 +37958,10 @@ var ts; return context.nextTokenSpan.kind !== 20; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 177; + return context.contextNode.kind === 178; }; - Rules.IsSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine(); + Rules.IsNonJsxSameLineTokenContext = function (context) { + return context.TokensAreOnSameLine() && context.contextNode.kind !== 240; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -36804,41 +37976,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 140; + return node.kind === 141; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 215 && + return context.currentTokenParent.kind === 216 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 221; + return context.contextNode.kind === 222; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 156; + return context.contextNode.kind === 157; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 && token.kind !== 27) { return false; } switch (parent.kind) { - case 152: - case 174: - case 217: - case 189: + case 153: + case 175: case 218: - case 216: - case 176: + case 190: + case 219: + case 217: case 177: + case 178: + case 145: case 144: - case 143: - case 148: case 149: - case 171: + case 150: case 172: - case 191: + case 173: + case 192: return true; default: return false; @@ -36849,13 +38021,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 174; + return context.contextNode.kind === 175; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 180; + return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 181; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 187 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 188 && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -36877,7 +38049,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 135 + 1; + this.mapRowLength = 136 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -37053,7 +38225,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 135; token++) { + for (var token = 0; token <= 136; token++) { result.push(token); } return result; @@ -37095,9 +38267,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(70, 135); + TokenRange.Keywords = TokenRange.FromRange(70, 136); TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 135, 116, 124]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 136, 116, 124]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41, 42, 50, 49]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 69, 17, 19, 15, 97, 92]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); @@ -37105,7 +38277,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([69, 128, 130, 120, 131, 103, 117]); + TokenRange.TypeNames = TokenRange.FromTokens([69, 129, 131, 120, 132, 103, 117]); return TokenRange; }()); Shared.TokenRange = TokenRange; @@ -37284,17 +38456,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 217: case 218: + case 219: return ts.rangeContainsRange(parent.members, node); - case 221: - var body = parent.body; - return body && body.kind === 195 && ts.rangeContainsRange(body.statements, node); - case 251: - case 195: case 222: + var body = parent.body; + return body && body.kind === 196 && ts.rangeContainsRange(body.statements, node); + case 252: + case 196: + case 223: return ts.rangeContainsRange(parent.statements, node); - case 247: + case 248: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -37449,18 +38621,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 217: return 73; - case 218: return 107; - case 216: return 87; - case 220: return 220; - case 146: return 123; - case 147: return 129; - case 144: + case 218: return 73; + case 219: return 107; + case 217: return 87; + case 221: return 221; + case 147: return 123; + case 148: return 130; + case 145: if (node.asteriskToken) { return 37; } - case 142: - case 139: + case 143: + case 140: return node.name.kind; } } @@ -37573,7 +38745,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 140 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 141 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -37876,20 +39048,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 195: - case 222: + case 196: + case 223: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 145: - case 216: - case 176: - case 144: - case 143: + case 146: + case 217: case 177: + case 145: + case 144: + case 178: if (node.typeParameters === list) { return 25; } @@ -37897,8 +39069,8 @@ var ts; return 17; } break; - case 171: case 172: + case 173: if (node.typeArguments === list) { return 25; } @@ -37906,7 +39078,7 @@ var ts; return 17; } break; - case 152: + case 153: if (node.typeArguments === list) { return 25; } @@ -37934,7 +39106,7 @@ var ts; if (!options.ConvertTabsToSpaces) { var tabs = Math.floor(indentation / options.TabSize); var spaces = indentation - tabs * options.TabSize; - var tabString; + var tabString = void 0; if (!internedTabsIndentation) { internedTabsIndentation = []; } @@ -37947,7 +39119,7 @@ var ts; return spaces ? tabString + repeat(" ", spaces) : tabString; } else { - var spacesString; + var spacesString = void 0; var quotient = Math.floor(indentation / options.IndentSize); var remainder = indentation % options.IndentSize; if (!internedSpacesIndentation) { @@ -38007,7 +39179,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 184) { + if (precedingToken.kind === 24 && precedingToken.parent.kind !== 185) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -38105,7 +39277,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 251 || !parentAndChildShareLine); + (parent.kind === 252 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -38129,7 +39301,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 199 && parent.elseStatement === child) { + if (parent.kind === 200 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -38141,23 +39313,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 152: + case 153: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 168: + case 169: return node.parent.properties; - case 167: + case 168: return node.parent.elements; - case 216: - case 176: + case 217: case 177: + case 178: + case 145: case 144: - case 143: - case 148: - case 149: { + case 149: + case 150: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -38168,8 +39340,8 @@ var ts; } break; } - case 172: - case 171: { + case 173: + case 172: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -38197,8 +39369,8 @@ var ts; if (node.kind === 18) { return -1; } - if (node.parent && (node.parent.kind === 171 || - node.parent.kind === 172) && + if (node.parent && (node.parent.kind === 172 || + node.parent.kind === 173) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -38216,10 +39388,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 171: case 172: - case 169: + case 173: case 170: + case 171: node = node.expression; break; default: @@ -38273,45 +39445,45 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 198: - case 217: - case 189: + case 199: case 218: - case 220: + case 190: case 219: - case 167: - case 195: - case 222: + case 221: + case 220: case 168: - case 156: - case 158: - case 223: - case 245: - case 244: - case 175: - case 169: - case 171: - case 172: case 196: - case 214: - case 230: - case 207: - case 185: - case 165: - case 164: - case 238: - case 237: - case 243: - case 143: - case 148: - case 149: - case 139: - case 153: - case 154: - case 161: + case 223: + case 169: + case 157: + case 159: + case 224: + case 246: + case 245: + case 176: + case 170: + case 172: case 173: - case 181: - case 228: + case 197: + case 215: + case 231: + case 208: + case 186: + case 166: + case 165: + case 239: + case 238: + case 244: + case 144: + case 149: + case 150: + case 140: + case 154: + case 155: + case 162: + case 174: + case 182: + case 229: return true; } return false; @@ -38319,22 +39491,22 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 200: case 201: - case 203: - case 204: case 202: - case 199: - case 216: - case 176: - case 144: + case 204: + case 205: + case 203: + case 200: + case 217: case 177: case 145: + case 178: case 146: case 147: - return childKind !== 195; - case 236: - return childKind !== 240; + case 148: + return childKind !== 196; + case 237: + return childKind !== 241; } return indentByDefault; } @@ -38346,11 +39518,6 @@ var ts; })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -var __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 ts; (function (ts) { ts.servicesVersion = "0.4"; @@ -38463,13 +39630,13 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 2048, this)); + nodes.push(createNode(token, pos, textPos, 0, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(274, nodes.pos, nodes.end, 2048, this); + var list = createNode(275, nodes.pos, nodes.end, 0, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -38488,27 +39655,27 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 136) { + if (this.kind >= 137) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; - var pos = this.pos; + var pos_3 = this.pos; var processNode = function (node) { - if (pos < node.pos) { - pos = _this.addSyntheticNodes(children, pos, node.pos); + if (pos_3 < node.pos) { + pos_3 = _this.addSyntheticNodes(children, pos_3, node.pos); } children.push(node); - pos = node.end; + pos_3 = node.end; }; var processNodes = function (nodes) { - if (pos < nodes.pos) { - pos = _this.addSyntheticNodes(children, pos, nodes.pos); + if (pos_3 < nodes.pos) { + pos_3 = _this.addSyntheticNodes(children, pos_3, nodes.pos); } children.push(_this.createSyntaxList(nodes)); - pos = nodes.end; + pos_3 = nodes.end; }; ts.forEachChild(this, processNode, processNodes); - if (pos < this.end) { - this.addSyntheticNodes(children, pos, this.end); + if (pos_3 < this.end) { + this.addSyntheticNodes(children, pos_3, this.end); } scanner.setText(undefined); } @@ -38535,7 +39702,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 136 ? child : child.getFirstToken(sourceFile); + return child.kind < 137 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -38543,7 +39710,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 136 ? child : child.getLastToken(sourceFile); + return child.kind < 137 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -38584,23 +39751,23 @@ var ts; var jsDocCommentParts = []; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { - var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 139) { - ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + var sourceFileOfDeclaration_1 = ts.getSourceFileOfNode(declaration); + if (canUseParsedParamTagComments && declaration.kind === 140) { + ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration_1), function (jsDocCommentTextRange) { + var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration_1); if (cleanedParamJsDocComment) { ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); } }); } - if (declaration.kind === 221 && declaration.body.kind === 221) { + if (declaration.kind === 222 && declaration.body.kind === 222) { return; } - while (declaration.kind === 221 && declaration.parent.kind === 221) { + while (declaration.kind === 222 && declaration.parent.kind === 222) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 214 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + ts.forEach(getJsDocCommentTextRange(declaration.kind === 215 ? declaration.parent.parent : declaration, sourceFileOfDeclaration_1), function (jsDocCommentTextRange) { + var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration_1); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); } @@ -38910,9 +40077,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 137) { + if (declaration.name.kind === 138) { var expr = declaration.name.expression; - if (expr.kind === 169) { + if (expr.kind === 170) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -38932,9 +40099,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 216: + case 217: + case 145: case 144: - case 143: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -38951,62 +40118,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 217: case 218: case 219: case 220: case 221: - case 224: - case 233: - case 229: - case 224: - case 226: - case 227: - case 146: - case 147: - case 156: - addDeclaration(node); - case 145: - case 196: - case 215: - case 164: - case 165: case 222: + case 225: + case 234: + case 230: + case 225: + case 227: + case 228: + case 147: + case 148: + case 157: + addDeclaration(node); + case 146: + case 197: + case 216: + case 165: + case 166: + case 223: ts.forEachChild(node, visit); break; - case 195: + case 196: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 139: - if (!(node.flags & 56)) { + case 140: + if (!(node.flags & 28)) { break; } - case 214: - case 166: + case 215: + case 167: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 250: + case 251: + case 143: case 142: - case 141: addDeclaration(node); break; - case 231: + case 232: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 225: + case 226: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227) { + if (importClause.namedBindings.kind === 228) { addDeclaration(importClause.namedBindings); } else { @@ -39160,14 +40327,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 176) { + if (declaration.kind === 177) { return true; } - if (declaration.kind !== 214 && declaration.kind !== 216) { + if (declaration.kind !== 215 && declaration.kind !== 217) { return false; } - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { - if (parent_9.kind === 251 || parent_9.kind === 222) { + for (var parent_10 = declaration.parent; !ts.isFunctionBlock(parent_10); parent_10 = parent_10.parent) { + if (parent_10.kind === 252 || parent_10.kind === 223) { return false; } } @@ -39177,7 +40344,6 @@ var ts; function getDefaultCompilerOptions() { return { target: 1, - module: 0, jsx: 1 }; } @@ -39200,12 +40366,14 @@ var ts; }; HostCache.prototype.createEntry = function (fileName, path) { var entry; + var scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : 0; var scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { entry = { hostFileName: fileName, version: this.host.getScriptVersion(fileName), - scriptSnapshot: scriptSnapshot + scriptSnapshot: scriptSnapshot, + scriptKind: scriptKind ? scriptKind : ts.getScriptKindFromFileName(fileName) }; } this.fileNameToEntry.set(path, entry); @@ -39252,10 +40420,11 @@ var ts; if (!scriptSnapshot) { throw new Error("Could not find file: '" + fileName + "'."); } + var scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : 0; var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true, scriptKind); } else if (this.currentFileVersion !== version) { var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); @@ -39278,6 +40447,7 @@ var ts; function transpileModule(input, transpileOptions) { var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; + options.suppressOutputPathCheck = true; options.allowNonTsExtensions = true; options.noLib = true; options.noResolve = true; @@ -39329,11 +40499,10 @@ var ts; return output.outputText; } ts.transpile = transpile; - function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { + function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) { var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); - var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents); + var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents, scriptKind); setSourceFileFields(sourceFile, scriptSnapshot, version); - sourceFile.nameTable = sourceFile.identifiers; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; @@ -39342,7 +40511,7 @@ var ts; if (textChangeRange) { if (version !== sourceFile.version) { if (!ts.disableIncrementalParsing) { - var newText; + var newText = void 0; var prefix = textChangeRange.span.start !== 0 ? sourceFile.text.substr(0, textChangeRange.span.start) : ""; @@ -39373,7 +40542,7 @@ var ts; } } } - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true, sourceFile.scriptKind); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { @@ -39410,19 +40579,19 @@ var ts; }); return JSON.stringify(bucketInfoArray, undefined, 2); } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true); + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true, scriptKind); } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false); + function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false, scriptKind); } - function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { + function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring, scriptKind) { var bucket = getBucketForCompilationSettings(compilationSettings, true); var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var entry = bucket.get(path); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false, scriptKind); entry = { sourceFile: sourceFile, languageServiceRefCount: 0, @@ -39520,7 +40689,7 @@ var ts; else { if (token === 69 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 133) { + if (token === 134) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -39546,7 +40715,7 @@ var ts; } if (token === 16) { token = scanner.scan(); - if (token === 133) { + if (token === 134) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -39560,7 +40729,7 @@ var ts; token = scanner.scan(); if (token === 69 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 133) { + if (token === 134) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -39585,7 +40754,7 @@ var ts; } if (token === 16) { token = scanner.scan(); - if (token === 133) { + if (token === 134) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -39595,7 +40764,7 @@ var ts; } else if (token === 37) { token = scanner.scan(); - if (token === 133) { + if (token === 134) { token = scanner.scan(); if (token === 9) { recordModuleName(); @@ -39619,7 +40788,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? scanner.scan() : scanner.getToken(); - if (token === 127) { + if (token === 128) { token = scanner.scan(); if (token === 17) { token = scanner.scan(); @@ -39692,7 +40861,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 210 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 211 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -39701,16 +40870,16 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 69 && - (node.parent.kind === 206 || node.parent.kind === 205) && + (node.parent.kind === 207 || node.parent.kind === 206) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 69 && - node.parent.kind === 210 && + node.parent.kind === 211 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 210; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 211; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -39721,25 +40890,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 136 && node.parent.right === node; + return node.parent.kind === 137 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 169 && node.parent.name === node; + return node && node.parent && node.parent.kind === 170 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 171 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 172 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 172 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 173 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 221 && node.parent.name === node; + return node.parent.kind === 222 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 69 && @@ -39747,22 +40916,22 @@ var ts; } function isNameOfPropertyAssignment(node) { return (node.kind === 69 || node.kind === 9 || node.kind === 8) && - (node.parent.kind === 248 || node.parent.kind === 249) && node.parent.name === node; + (node.parent.kind === 249 || node.parent.kind === 250) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 142: - case 141: - case 248: - case 250: - case 144: case 143: - case 146: + case 142: + case 249: + case 251: + case 145: + case 144: case 147: - case 221: + case 148: + case 222: return node.parent.name === node; - case 170: + case 171: return node.parent.argumentExpression === node; } } @@ -39800,7 +40969,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 70; i <= 135; i++) { + for (var i = 70; i <= 136; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -39815,17 +40984,17 @@ var ts; return undefined; } switch (node.kind) { - case 251: + case 252: + case 145: case 144: - case 143: - case 216: - case 176: - case 146: - case 147: case 217: + case 177: + case 147: + case 148: case 218: - case 220: + case 219: case 221: + case 222: return node; } } @@ -39833,38 +41002,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 221: return ScriptElementKind.moduleElement; - case 217: return ScriptElementKind.classElement; - case 218: return ScriptElementKind.interfaceElement; - case 219: return ScriptElementKind.typeElement; - case 220: return ScriptElementKind.enumElement; - case 214: + case 222: return ScriptElementKind.moduleElement; + case 218: return ScriptElementKind.classElement; + case 219: return ScriptElementKind.interfaceElement; + case 220: return ScriptElementKind.typeElement; + case 221: return ScriptElementKind.enumElement; + case 215: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 216: return ScriptElementKind.functionElement; - case 146: return ScriptElementKind.memberGetAccessorElement; - case 147: return ScriptElementKind.memberSetAccessorElement; + case 217: return ScriptElementKind.functionElement; + case 147: return ScriptElementKind.memberGetAccessorElement; + case 148: return ScriptElementKind.memberSetAccessorElement; + case 145: case 144: - case 143: return ScriptElementKind.memberFunctionElement; + case 143: case 142: - case 141: return ScriptElementKind.memberVariableElement; - case 150: return ScriptElementKind.indexSignatureElement; - case 149: return ScriptElementKind.constructSignatureElement; - case 148: return ScriptElementKind.callSignatureElement; - case 145: return ScriptElementKind.constructorImplementationElement; - case 138: return ScriptElementKind.typeParameterElement; - case 250: return ScriptElementKind.variableElement; - case 139: return (node.flags & 56) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 224: - case 229: - case 226: - case 233: + case 151: return ScriptElementKind.indexSignatureElement; + case 150: return ScriptElementKind.constructSignatureElement; + case 149: return ScriptElementKind.callSignatureElement; + case 146: return ScriptElementKind.constructorImplementationElement; + case 139: return ScriptElementKind.typeParameterElement; + case 251: return ScriptElementKind.variableElement; + case 140: return (node.flags & 28) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 225: + case 230: case 227: + case 234: + case 228: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -39960,6 +41129,9 @@ var ts; return ts.directoryProbablyExists(directoryName, host); } }; + if (host.trace) { + compilerHost.trace = function (message) { return host.trace(message); }; + } if (host.resolveModuleNames) { compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; } @@ -39986,10 +41158,11 @@ var ts; if (!changesInCompilationSettingsAffectSyntax) { var oldSourceFile = program && program.getSourceFile(fileName); if (oldSourceFile) { - return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + fileName); + return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } } - return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } function sourceFileUpToDate(sourceFile) { if (!sourceFile) { @@ -40093,9 +41266,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 272: - case 270: + case 273: case 271: + case 272: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -40130,13 +41303,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; + var parent_11 = contextToken.parent, kind = contextToken.kind; if (kind === 21) { - if (parent_10.kind === 169) { + if (parent_11.kind === 170) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 136) { + else if (parent_11.kind === 137) { node = contextToken.parent.left; isRightOfDot = true; } @@ -40149,7 +41322,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 && contextToken.parent.kind === 240) { + else if (kind === 39 && contextToken.parent.kind === 241) { isStartingCloseTag = true; location = contextToken; } @@ -40192,7 +41365,7 @@ var ts; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 || node.kind === 136 || node.kind === 169) { + if (node.kind === 69 || node.kind === 137 || node.kind === 170) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -40237,8 +41410,8 @@ var ts; return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { - var attrsType; - if ((jsxContainer.kind === 237) || (jsxContainer.kind === 238)) { + var attrsType = void 0; + if ((jsxContainer.kind === 238) || (jsxContainer.kind === 239)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -40278,15 +41451,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 239) { + if (contextToken.kind === 240) { return true; } if (contextToken.kind === 27 && contextToken.parent) { - if (contextToken.parent.kind === 238) { + if (contextToken.parent.kind === 239) { return true; } - if (contextToken.parent.kind === 240 || contextToken.parent.kind === 237) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 236; + if (contextToken.parent.kind === 241 || contextToken.parent.kind === 238) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 237; } } return false; @@ -40296,40 +41469,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24: - return containingNodeKind === 171 - || containingNodeKind === 145 - || containingNodeKind === 172 - || containingNodeKind === 167 - || containingNodeKind === 184 - || containingNodeKind === 153; + return containingNodeKind === 172 + || containingNodeKind === 146 + || containingNodeKind === 173 + || containingNodeKind === 168 + || containingNodeKind === 185 + || containingNodeKind === 154; case 17: - return containingNodeKind === 171 - || containingNodeKind === 145 - || containingNodeKind === 172 - || containingNodeKind === 175 - || containingNodeKind === 161; + return containingNodeKind === 172 + || containingNodeKind === 146 + || containingNodeKind === 173 + || containingNodeKind === 176 + || containingNodeKind === 162; case 19: - return containingNodeKind === 167 - || containingNodeKind === 150 - || containingNodeKind === 137; + return containingNodeKind === 168 + || containingNodeKind === 151 + || containingNodeKind === 138; case 125: case 126: return true; case 21: - return containingNodeKind === 221; + return containingNodeKind === 222; case 15: - return containingNodeKind === 217; + return containingNodeKind === 218; case 56: - return containingNodeKind === 214 - || containingNodeKind === 184; + return containingNodeKind === 215 + || containingNodeKind === 185; case 12: - return containingNodeKind === 186; + return containingNodeKind === 187; case 13: - return containingNodeKind === 193; + return containingNodeKind === 194; case 112: case 110: case 111: - return containingNodeKind === 142; + return containingNodeKind === 143; } switch (previousToken.getText()) { case "public": @@ -40342,7 +41515,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 - || contextToken.kind === 163 + || contextToken.kind === 164 || contextToken.kind === 10 || ts.isTemplateLiteralKind(contextToken.kind)) { var start_7 = contextToken.getStart(); @@ -40361,12 +41534,12 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 168) { + if (objectLikeContainer.kind === 169) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 164) { + else if (objectLikeContainer.kind === 165) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { @@ -40392,9 +41565,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 228 ? - 225 : - 231; + var declarationKind = namedImportsOrExports.kind === 229 ? + 226 : + 232; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -40415,9 +41588,9 @@ var ts; switch (contextToken.kind) { case 15: case 24: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 168 || parent_11.kind === 164)) { - return parent_11; + var parent_12 = contextToken.parent; + if (parent_12 && (parent_12.kind === 169 || parent_12.kind === 165)) { + return parent_12; } break; } @@ -40430,8 +41603,8 @@ var ts; case 15: case 24: switch (contextToken.parent.kind) { - case 228: - case 232: + case 229: + case 233: return contextToken.parent; } } @@ -40440,34 +41613,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_13 = contextToken.parent; switch (contextToken.kind) { case 26: case 39: case 69: - case 241: case 242: - if (parent_12 && (parent_12.kind === 237 || parent_12.kind === 238)) { - return parent_12; + case 243: + if (parent_13 && (parent_13.kind === 238 || parent_13.kind === 239)) { + return parent_13; } - else if (parent_12.kind === 241) { - return parent_12.parent; + else if (parent_13.kind === 242) { + return parent_13.parent; } break; case 9: - if (parent_12 && ((parent_12.kind === 241) || (parent_12.kind === 242))) { - return parent_12.parent; + if (parent_13 && ((parent_13.kind === 242) || (parent_13.kind === 243))) { + return parent_13.parent; } break; case 16: - if (parent_12 && - parent_12.kind === 243 && - parent_12.parent && - (parent_12.parent.kind === 241)) { - return parent_12.parent.parent; + if (parent_13 && + parent_13.kind === 244 && + parent_13.parent && + (parent_13.parent.kind === 242)) { + return parent_13.parent.parent; } - if (parent_12 && parent_12.kind === 242) { - return parent_12.parent; + if (parent_13 && parent_13.kind === 243) { + return parent_13.parent; } break; } @@ -40476,16 +41649,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 176: case 177: - case 216: + case 178: + case 217: + case 145: case 144: - case 143: - case 146: case 147: case 148: case 149: case 150: + case 151: return true; } return false; @@ -40494,66 +41667,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24: - return containingNodeKind === 214 || - containingNodeKind === 215 || - containingNodeKind === 196 || - containingNodeKind === 220 || + return containingNodeKind === 215 || + containingNodeKind === 216 || + containingNodeKind === 197 || + containingNodeKind === 221 || isFunction(containingNodeKind) || - containingNodeKind === 217 || - containingNodeKind === 189 || containingNodeKind === 218 || - containingNodeKind === 165 || - containingNodeKind === 219; + containingNodeKind === 190 || + containingNodeKind === 219 || + containingNodeKind === 166 || + containingNodeKind === 220; case 21: - return containingNodeKind === 165; - case 54: return containingNodeKind === 166; + case 54: + return containingNodeKind === 167; case 19: - return containingNodeKind === 165; + return containingNodeKind === 166; case 17: - return containingNodeKind === 247 || + return containingNodeKind === 248 || isFunction(containingNodeKind); case 15: - return containingNodeKind === 220 || - containingNodeKind === 218 || - containingNodeKind === 156; - case 23: - return containingNodeKind === 141 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 218 || - contextToken.parent.parent.kind === 156); - case 25: - return containingNodeKind === 217 || - containingNodeKind === 189 || - containingNodeKind === 218 || + return containingNodeKind === 221 || containingNodeKind === 219 || + containingNodeKind === 157; + case 23: + return containingNodeKind === 142 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 219 || + contextToken.parent.parent.kind === 157); + case 25: + return containingNodeKind === 218 || + containingNodeKind === 190 || + containingNodeKind === 219 || + containingNodeKind === 220 || isFunction(containingNodeKind); case 113: - return containingNodeKind === 142; + return containingNodeKind === 143; case 22: - return containingNodeKind === 139 || + return containingNodeKind === 140 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 165); + contextToken.parent.parent.kind === 166); case 112: case 110: case 111: - return containingNodeKind === 139; + return containingNodeKind === 140; case 116: - return containingNodeKind === 229 || - containingNodeKind === 233 || - containingNodeKind === 227; + return containingNodeKind === 230 || + containingNodeKind === 234 || + containingNodeKind === 228; case 73: case 81: case 107: case 87: case 102: case 123: - case 129: + case 130: case 89: case 108: case 74: case 114: - case 132: + case 133: return true; } switch (contextToken.getText()) { @@ -40584,19 +41757,19 @@ var ts; return false; } function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { - var exisingImportsOrExports = {}; + var existingImportsOrExports = {}; for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { var element = namedImportsOrExports_1[_i]; if (element.getStart() <= position && position <= element.getEnd()) { continue; } var name_34 = element.propertyName || element.name; - exisingImportsOrExports[name_34.text] = true; + existingImportsOrExports[name_34.text] = true; } - if (ts.isEmpty(exisingImportsOrExports)) { + if (ts.isEmpty(existingImportsOrExports)) { return exportsOfModule; } - return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); + return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(existingImportsOrExports, e.name); }); } function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { @@ -40605,17 +41778,17 @@ var ts; var existingMemberNames = {}; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 248 && - m.kind !== 249 && - m.kind !== 166 && - m.kind !== 144) { + if (m.kind !== 249 && + m.kind !== 250 && + m.kind !== 167 && + m.kind !== 145) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 166 && m.propertyName) { + if (m.kind === 167 && m.propertyName) { if (m.propertyName.kind === 69) { existingName = m.propertyName.text; } @@ -40634,7 +41807,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 241) { + if (attr.kind === 242) { seenNames[attr.name.text] = true; } } @@ -40647,20 +41820,20 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; if (isJsDocTagName) { return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; } var sourceFile = getValidSourceFile(fileName); var entries = []; - if (isRightOfDot && ts.isSourceFileJavaScript(sourceFile)) { + if (ts.isSourceFileJavaScript(sourceFile)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 240) { + location.parent && location.parent.kind === 241) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -40679,11 +41852,14 @@ var ts; ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, uniqueNames) { + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var target = program.getCompilerOptions().target; var nameTable = getNameTable(sourceFile); for (var name_35 in nameTable) { + if (nameTable[name_35] === position) { + continue; + } if (!uniqueNames[name_35]) { uniqueNames[name_35] = name_35; var displayName = getCompletionEntryDisplayName(name_35, target, true); @@ -40726,8 +41902,8 @@ var ts; var start = new Date().getTime(); var uniqueNames = {}; if (symbols) { - for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { - var symbol = symbols_3[_i]; + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); @@ -40747,8 +41923,8 @@ var ts; var completionData = getCompletionData(fileName, position); if (completionData) { var symbols = completionData.symbols, location_2 = completionData.location; - var target = program.getCompilerOptions().target; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); + var target_2 = program.getCompilerOptions().target; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target_2, false, location_2) === entryName ? s : undefined; }); if (symbol) { var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { @@ -40775,7 +41951,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 189) ? + return ts.getDeclarationOfKind(symbol, 190) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384) return ScriptElementKind.enumElement; @@ -40868,17 +42044,17 @@ var ts; if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { symbolKind = ScriptElementKind.memberVariableElement; } - var signature; + var signature = void 0; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 169) { + if (location.parent && location.parent.kind === 170) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } - var callExpression; - if (location.kind === 171 || location.kind === 172) { + var callExpression = void 0; + if (location.kind === 172 || location.kind === 173) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -40890,7 +42066,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 172 || callExpression.expression.kind === 95; + var useConstructSignatures = callExpression.kind === 173 || callExpression.expression.kind === 95; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -40938,21 +42114,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 121 && location.parent.kind === 145)) { + (location.kind === 121 && location.parent.kind === 146)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 145 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 146 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 145) { + if (functionDeclaration.kind === 146) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 148 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 149 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -40961,7 +42137,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 189)) { + if (ts.getDeclarationOfKind(symbol, 190)) { pushTypePart(ScriptElementKind.localClassElement); } else { @@ -40980,7 +42156,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(132)); + displayParts.push(ts.keywordPart(133)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -41001,7 +42177,7 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 221); + var declaration = ts.getDeclarationOfKind(symbol, 222); var isNamespace = declaration && declaration.name && declaration.name.kind === 69; displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); displayParts.push(ts.spacePart()); @@ -41022,23 +42198,23 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 138); + var declaration = ts.getDeclarationOfKind(symbol, 139); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 149) { + if (declaration.kind === 150) { displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 148 && declaration.name) { + else if (declaration.kind !== 149 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } else { - displayParts.push(ts.keywordPart(132)); + displayParts.push(ts.keywordPart(133)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -41049,7 +42225,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 250) { + if (declaration.kind === 251) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -41065,13 +42241,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 224) { + if (declaration.kind === 225) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(56)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127)); + displayParts.push(ts.keywordPart(128)); displayParts.push(ts.punctuationPart(17)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18)); @@ -41195,10 +42371,10 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 69: - case 169: - case 136: + case 170: + case 137: case 97: - case 162: + case 163: case 95: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -41271,8 +42447,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 145) || - (!selectConstructors && (d.kind === 216 || d.kind === 144 || d.kind === 143))) { + if ((selectConstructors && d.kind === 146) || + (!selectConstructors && (d.kind === 217 || d.kind === 145 || d.kind === 144))) { declarations.push(d); if (d.body) definition = d; @@ -41323,20 +42499,22 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 69 && node.parent === declaration) { + if (node.kind === 69 && + (node.parent === declaration || + (declaration.kind === 230 && declaration.parent && declaration.parent.kind === 229))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 249) { + if (node.parent.kind === 250) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; } var shorthandDeclarations = shorthandSymbol.getDeclarations(); - var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node); - var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol); - var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); - return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); + var shorthandSymbolKind_1 = getSymbolKind(shorthandSymbol, node); + var shorthandSymbolName_1 = typeChecker.symbolToString(shorthandSymbol); + var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } return getDefinitionFromSymbol(symbol, node); } @@ -41357,13 +42535,13 @@ var ts; return undefined; } if (type.flags & 16384) { - var result = []; + var result_3 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(result_3, getDefinitionFromSymbol(t.symbol, node)); } }); - return result; + return result_3; } if (!type.symbol) { return undefined; @@ -41373,8 +42551,8 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); + var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); } return results; } @@ -41400,7 +42578,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 69 || node.kind === 97 || - node.kind === 162 || + node.kind === 163 || node.kind === 95 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { @@ -41452,75 +42630,75 @@ var ts; switch (node.kind) { case 88: case 80: - if (hasKind(node.parent, 199)) { + if (hasKind(node.parent, 200)) { return getIfElseOccurrences(node.parent); } break; case 94: - if (hasKind(node.parent, 207)) { + if (hasKind(node.parent, 208)) { return getReturnOccurrences(node.parent); } break; case 98: - if (hasKind(node.parent, 211)) { + if (hasKind(node.parent, 212)) { return getThrowOccurrences(node.parent); } break; case 72: - if (hasKind(parent(parent(node)), 212)) { + if (hasKind(parent(parent(node)), 213)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 100: case 85: - if (hasKind(parent(node), 212)) { + if (hasKind(parent(node), 213)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 96: - if (hasKind(node.parent, 209)) { + if (hasKind(node.parent, 210)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 71: case 77: - if (hasKind(parent(parent(parent(node))), 209)) { + if (hasKind(parent(parent(parent(node))), 210)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 70: case 75: - if (hasKind(node.parent, 206) || hasKind(node.parent, 205)) { + if (hasKind(node.parent, 207) || hasKind(node.parent, 206)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 86: - if (hasKind(node.parent, 202) || - hasKind(node.parent, 203) || - hasKind(node.parent, 204)) { + if (hasKind(node.parent, 203) || + hasKind(node.parent, 204) || + hasKind(node.parent, 205)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 104: case 79: - if (hasKind(node.parent, 201) || hasKind(node.parent, 200)) { + if (hasKind(node.parent, 202) || hasKind(node.parent, 201)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 121: - if (hasKind(node.parent, 145)) { + if (hasKind(node.parent, 146)) { return getConstructorOccurrences(node.parent); } break; case 123: - case 129: - if (hasKind(node.parent, 146) || hasKind(node.parent, 147)) { + case 130: + if (hasKind(node.parent, 147) || hasKind(node.parent, 148)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 196)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 197)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -41532,10 +42710,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211) { + if (node.kind === 212) { statementAccumulator.push(node); } - else if (node.kind === 212) { + else if (node.kind === 213) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -41555,17 +42733,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 === 251) { - return parent_13; + var parent_14 = child.parent; + if (ts.isFunctionBlock(parent_14) || parent_14.kind === 252) { + return parent_14; } - if (parent_13.kind === 212) { - var tryStatement = parent_13; + if (parent_14.kind === 213) { + var tryStatement = parent_14; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_14; } return undefined; } @@ -41574,7 +42752,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206 || node.kind === 205) { + if (node.kind === 207 || node.kind === 206) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -41589,15 +42767,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 209: - if (statement.kind === 205) { + case 210: + if (statement.kind === 206) { continue; } - case 202: case 203: case 204: + case 205: + case 202: case 201: - case 200: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -41614,24 +42792,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 217 || - container.kind === 189 || - (declaration.kind === 139 && hasKind(container, 145)))) { + if (!(container.kind === 218 || + container.kind === 190 || + (declaration.kind === 140 && hasKind(container, 146)))) { return undefined; } } else if (modifier === 113) { - if (!(container.kind === 217 || container.kind === 189)) { + if (!(container.kind === 218 || container.kind === 190)) { return undefined; } } else if (modifier === 82 || modifier === 122) { - if (!(container.kind === 222 || container.kind === 251)) { + if (!(container.kind === 223 || container.kind === 252)) { return undefined; } } else if (modifier === 115) { - if (!(container.kind === 217 || declaration.kind === 217)) { + if (!(container.kind === 218 || declaration.kind === 218)) { return undefined; } } @@ -41642,8 +42820,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 222: - case 251: + case 223: + case 252: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -41651,15 +42829,15 @@ var ts; nodes = container.statements; } break; - case 145: + case 146: nodes = container.parameters.concat(container.parent.members); break; - case 217: - case 189: + case 218: + case 190: nodes = container.members; - if (modifierFlag & 56) { + if (modifierFlag & 28) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 145 && member; + return member.kind === 146 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -41681,17 +42859,17 @@ var ts; function getFlagFromModifier(modifier) { switch (modifier) { case 112: - return 8; - case 110: - return 16; - case 111: - return 32; - case 113: - return 64; - case 82: - return 2; - case 122: return 4; + case 110: + return 8; + case 111: + return 16; + case 113: + return 32; + case 82: + return 1; + case 122: + return 2; case 115: return 128; default: @@ -41712,13 +42890,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 146); tryPushAccessorKeyword(accessorDeclaration.symbol, 147); + tryPushAccessorKeyword(accessorDeclaration.symbol, 148); 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, 123, 129); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123, 130); }); } } } @@ -41735,7 +42913,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { - if (loopNode.kind === 200) { + if (loopNode.kind === 201) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 104)) { @@ -41756,13 +42934,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 202: case 203: case 204: - case 200: + case 205: case 201: + case 202: return getLoopBreakContinueOccurrences(owner); - case 209: + case 210: return getSwitchCaseDefaultOccurrences(owner); } } @@ -41812,7 +42990,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 195))) { + if (!(func && hasKind(func.body, 196))) { return undefined; } var keywords = []; @@ -41826,7 +43004,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 199) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 200) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -41837,7 +43015,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 199)) { + if (!hasKind(ifStatement.elseStatement, 200)) { break; } ifStatement = ifStatement.elseStatement; @@ -41941,7 +43119,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 || node.kind === 162) { + if (node.kind === 97 || node.kind === 163) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95) { @@ -41970,7 +43148,7 @@ var ts; var sourceFile = sourceFiles_3[_i]; cancellationToken.throwIfCancellationRequested(); var nameTable = getNameTable(sourceFile); - if (ts.lookUp(nameTable, internedName)) { + if (ts.lookUp(nameTable, internedName) !== undefined) { result = result || []; getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } @@ -41994,7 +43172,7 @@ var ts; }; } function isImportSpecifierSymbol(symbol) { - return (symbol.flags & 8388608) && !!ts.getDeclarationOfKind(symbol, 229); + return (symbol.flags & 8388608) && !!ts.getDeclarationOfKind(symbol, 230); } function getInternedName(symbol, location, declarations) { if (ts.isImportOrExportSpecifierName(location)) { @@ -42006,13 +43184,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 176 || valueDeclaration.kind === 189)) { + if (valueDeclaration && (valueDeclaration.kind === 177 || valueDeclaration.kind === 190)) { return valueDeclaration; } if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16) ? d : undefined; }); + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 8) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 217); + return ts.getAncestor(privateDeclaration, 218); } } if (symbol.flags & 8388608) { @@ -42024,8 +43202,8 @@ var ts; var scope; var declarations = symbol.getDeclarations(); if (declarations) { - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; @@ -42033,7 +43211,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 251 && !ts.isExternalModule(container)) { + if (container.kind === 252 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -42114,7 +43292,7 @@ var ts; var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= 0) { + else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } @@ -42178,15 +43356,15 @@ var ts; if (!searchSpaceNode) { return undefined; } - var staticFlag = 64; + var staticFlag = 32; switch (searchSpaceNode.kind) { - case 142: - case 141: - case 144: case 143: + case 142: case 145: + case 144: case 146: case 147: + case 148: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -42203,7 +43381,7 @@ var ts; return; } var container = ts.getSuperContainer(node, false); - if (container && (64 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + if (container && (32 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { references.push(getReferenceEntryFromNode(node)); } }); @@ -42212,34 +43390,34 @@ var ts; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 64; + var staticFlag = 32; switch (searchSpaceNode.kind) { + case 145: case 144: - case 143: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 143: case 142: - case 141: - case 145: case 146: case 147: + case 148: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 251: + case 252: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 216: - case 176: + case 217: + case 177: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 251) { + if (searchSpaceNode.kind === 252) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -42265,31 +43443,31 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 && node.kind !== 162)) { + if (!node || (node.kind !== 97 && node.kind !== 163)) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 176: - case 216: + case 177: + case 217: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 145: case 144: - case 143: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 189: - case 217: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64) === staticFlag) { + case 190: + case 218: + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 251: - if (container.kind === 251 && !ts.isExternalModule(container)) { + case 252: + if (container.kind === 252 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -42302,7 +43480,7 @@ var ts; if (isImportSpecifierSymbol(symbol)) { result.push(typeChecker.getAliasedSymbol(symbol)); } - if (location.parent.kind === 233) { + if (location.parent.kind === 234) { result.push(typeChecker.getExportSpecifierLocalTargetSymbol(location.parent)); } if (isNameOfPropertyAssignment(location)) { @@ -42314,7 +43492,7 @@ var ts; result.push(shorthandValueSymbol); } } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 139 && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 140 && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -42337,11 +43515,11 @@ var ts; } if (symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 217) { + if (declaration.kind === 218) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 218) { + else if (declaration.kind === 219) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -42371,7 +43549,7 @@ var ts; return aliasedSymbol; } } - if (referenceLocation.parent.kind === 233) { + if (referenceLocation.parent.kind === 234) { var aliasedSymbol = typeChecker.getExportSpecifierLocalTargetSymbol(referenceLocation.parent); if (searchSymbols.indexOf(aliasedSymbol) >= 0) { return aliasedSymbol; @@ -42387,9 +43565,9 @@ var ts; return rootSymbol; } if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - var result_3 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3, {}); - return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + var result_4 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, {}); + return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } return undefined; }); @@ -42406,14 +43584,14 @@ var ts; return [unionProperty]; } else { - var result_4 = []; + var result_5 = []; ts.forEach(contextualType.types, function (t) { var symbol = t.getProperty(name_36); if (symbol) { - result_4.push(symbol); + result_5.push(symbol); } }); - return result_4; + return result_5; } } else { @@ -42428,11 +43606,11 @@ var ts; } function getIntersectingMeaningFromDeclarations(meaning, declarations) { if (declarations) { - var lastIterationMeaning; + var lastIterationMeaning = void 0; do { lastIterationMeaning = meaning; - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; var declarationMeaning = getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -42462,10 +43640,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 183 || parent.kind === 182) { + if (parent.kind === 184 || parent.kind === 183) { return true; } - else if (parent.kind === 184 && parent.left === node) { + else if (parent.kind === 185 && parent.left === node) { var operator = parent.operatorToken.kind; return 56 <= operator && operator <= 68; } @@ -42495,33 +43673,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 139: - case 214: - case 166: + case 140: + case 215: + case 167: + case 143: case 142: - case 141: - case 248: case 249: case 250: - case 144: - case 143: + case 251: case 145: + case 144: case 146: case 147: - case 216: - case 176: - case 177: - case 247: - return 1; - case 138: - case 218: - case 219: - case 156: - return 2; + case 148: case 217: + case 177: + case 178: + case 248: + return 1; + case 139: + case 219: case 220: - return 1 | 2; + case 157: + return 2; + case 218: case 221: + return 1 | 2; + case 222: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -42531,14 +43709,14 @@ var ts; else { return 4; } - case 228: case 229: - case 224: - case 225: case 230: + case 225: + case 226: case 231: + case 232: return 1 | 2 | 4; - case 251: + case 252: return 4 | 1; } return 1 | 2 | 4; @@ -42547,10 +43725,10 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 152 || - (node.parent.kind === 191 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 153 || + (node.parent.kind === 192 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 97 && !ts.isExpression(node)) || - node.kind === 162; + node.kind === 163; } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -42558,47 +43736,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 169) { - while (root.parent && root.parent.kind === 169) { + if (root.parent.kind === 170) { + while (root.parent && root.parent.kind === 170) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 191 && root.parent.parent.kind === 246) { + if (!isLastClause && root.parent.kind === 192 && root.parent.parent.kind === 247) { var decl = root.parent.parent.parent; - return (decl.kind === 217 && root.parent.parent.token === 106) || - (decl.kind === 218 && root.parent.parent.token === 83); + return (decl.kind === 218 && root.parent.parent.token === 106) || + (decl.kind === 219 && root.parent.parent.token === 83); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 136) { - while (root.parent && root.parent.kind === 136) { + if (root.parent.kind === 137) { + while (root.parent && root.parent.kind === 137) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 152 && !isLastClause; + return root.parent.kind === 153 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 136) { + while (node.parent.kind === 137) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 69); - if (node.parent.kind === 136 && + if (node.parent.kind === 137 && node.parent.right === node && - node.parent.parent.kind === 224) { + node.parent.parent.kind === 225) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 230) { + if (node.parent.kind === 231) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -42632,16 +43810,16 @@ var ts; return; } switch (node.kind) { - case 169: - case 136: + case 170: + case 137: case 9: - case 163: + case 164: case 84: case 99: case 93: case 95: case 97: - case 162: + case 163: case 69: break; default: @@ -42653,7 +43831,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 221 && + if (nodeForStartPos.parent.parent.kind === 222 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -42680,10 +43858,10 @@ var ts; } function checkForClassificationCancellation(kind) { switch (kind) { - case 221: - case 217: + case 222: case 218: - case 216: + case 219: + case 217: cancellationToken.throwIfCancellationRequested(); } } @@ -42731,7 +43909,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 221 && + return declaration.kind === 222 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -42870,16 +44048,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 270: + case 271: processJSDocParameterTag(tag); break; - case 273: + case 274: processJSDocTemplateTag(tag); break; - case 272: + case 273: processElement(tag.typeExpression); break; - case 271: + case 272: processElement(tag.typeExpression); break; } @@ -42935,19 +44113,49 @@ var ts; pushClassification(start, end - start, type); } } - function classifyTokenOrJsxText(token) { - if (ts.nodeIsMissing(token)) { - return; + function tryClassifyNode(node) { + if (ts.nodeIsMissing(node)) { + return true; } - var tokenStart = token.kind === 239 ? token.pos : classifyLeadingTriviaAndGetTokenStart(token); - var tokenWidth = token.end - tokenStart; + var classifiedElementName = tryClassifyJsxElementName(node); + if (!ts.isToken(node) && node.kind !== 240 && classifiedElementName === undefined) { + return false; + } + var tokenStart = node.kind === 240 ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { - var type = classifyTokenType(token.kind, token); + var type = classifiedElementName || classifyTokenType(node.kind, node); if (type) { pushClassification(tokenStart, tokenWidth, type); } } + return true; + } + function tryClassifyJsxElementName(token) { + switch (token.parent && token.parent.kind) { + case 239: + if (token.parent.tagName === token) { + return 19; + } + break; + case 241: + if (token.parent.tagName === token) { + return 20; + } + break; + case 238: + if (token.parent.tagName === token) { + return 21; + } + break; + case 242: + if (token.parent.name === token) { + return 22; + } + break; + } + return undefined; } function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { @@ -42961,17 +44169,17 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 56) { - if (token.parent.kind === 214 || - token.parent.kind === 142 || - token.parent.kind === 139 || - token.parent.kind === 241) { + if (token.parent.kind === 215 || + token.parent.kind === 143 || + token.parent.kind === 140 || + token.parent.kind === 242) { return 5; } } - if (token.parent.kind === 184 || - token.parent.kind === 182 || + if (token.parent.kind === 185 || token.parent.kind === 183 || - token.parent.kind === 185) { + token.parent.kind === 184 || + token.parent.kind === 186) { return 5; } } @@ -42980,8 +44188,8 @@ var ts; else if (tokenKind === 8) { return 4; } - else if (tokenKind === 9 || tokenKind === 163) { - return token.parent.kind === 241 ? 24 : 6; + else if (tokenKind === 9 || tokenKind === 164) { + return token.parent.kind === 242 ? 24 : 6; } else if (tokenKind === 10) { return 6; @@ -42989,61 +44197,42 @@ var ts; else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 239) { + else if (tokenKind === 240) { return 23; } else if (tokenKind === 69) { if (token) { switch (token.parent.kind) { - case 217: + case 218: if (token.parent.name === token) { return 11; } return; - case 138: + case 139: if (token.parent.name === token) { return 15; } return; - case 218: + case 219: if (token.parent.name === token) { return 13; } return; - case 220: + case 221: if (token.parent.name === token) { return 12; } return; - case 221: + case 222: if (token.parent.name === token) { return 14; } return; - case 139: + case 140: if (token.parent.name === token) { return 17; } return; - case 238: - if (token.parent.tagName === token) { - return 19; - } - return; - case 240: - if (token.parent.tagName === token) { - return 20; - } - return; - case 237: - if (token.parent.tagName === token) { - return 21; - } - return; - case 241: - if (token.parent.name === token) { - return 22; - } } } return 2; @@ -43058,10 +44247,7 @@ var ts; var children = element.getChildren(sourceFile); for (var i = 0, n = children.length; i < n; i++) { var child = children[i]; - if (ts.isToken(child) || child.kind === 239) { - classifyTokenOrJsxText(child); - } - else { + if (!tryClassifyNode(child)) { processElement(child); } } @@ -43155,16 +44341,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 216: - case 144: - case 145: case 217: - case 196: + case 145: + case 146: + case 218: + case 197: break findOwner; - case 251: + case 252: return undefined; - case 221: - if (commentOwner.parent.kind === 221) { + case 222: + if (commentOwner.parent.kind === 222) { return undefined; } break findOwner; @@ -43177,7 +44363,7 @@ var ts; 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 newLine = ts.getNewLineOrDefaultFromHost(host); var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; @@ -43198,7 +44384,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 196) { + if (commentOwner.kind === 197) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -43208,17 +44394,17 @@ var ts; return emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 175) { + while (rightHandSide.kind === 176) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 176: case 177: + case 178: return rightHandSide.parameters; - case 189: + case 190: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 145) { + if (member.kind === 146) { return member.parameters; } } @@ -43234,7 +44420,7 @@ var ts; var result = []; if (descriptors.length > 0) { var regExp = getTodoCommentsRegExp(); - var matchArray; + var matchArray = void 0; while (matchArray = regExp.exec(fileContents)) { cancellationToken.throwIfCancellationRequested(); var firstDescriptorCaptureIndex = 3; @@ -43270,8 +44456,8 @@ var ts; function getTodoCommentsRegExp() { var singleLineCommentStart = /(?:\/\/+\s*)/.source; var multiLineCommentStart = /(?:\/\*+\s*)/.source; - var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; - var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + var anyNumberOfSpacesAndAsterisksAtStartOfLine = /(?:^(?:\s|\*)*)/.source; + var preamble = "(" + anyNumberOfSpacesAndAsterisksAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; @@ -43298,13 +44484,13 @@ var ts; var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); if (defaultLibFileName) { - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var current = declarations_10[_i]; - var sourceFile_2 = current.getSourceFile(); - if (!sourceFile_2) { + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var current = declarations_11[_i]; + var sourceFile_3 = current.getSourceFile(); + if (!sourceFile_3) { continue; } - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_3.fileName)); if (canonicalName === canonicalDefaultLibName) { return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); } @@ -43393,14 +44579,14 @@ var ts; function walk(node) { switch (node.kind) { case 69: - nameTable[node.text] = node.text; + nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 235 || + node.parent.kind === 236 || isArgumentOfElementAccessExpression(node)) { - nameTable[node.text] = node.text; + nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; } break; default: @@ -43411,7 +44597,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 170 && + node.parent.kind === 171 && node.parent.argumentExpression === node; } function createClassifier() { @@ -43433,7 +44619,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 123 || - keyword2 === 129 || + keyword2 === 130 || keyword2 === 121 || keyword2 === 113) { return true; @@ -43549,10 +44735,10 @@ var ts; angleBracketStack--; } else if (token === 117 || - token === 130 || - token === 128 || + token === 131 || + token === 129 || token === 120 || - token === 131) { + token === 132) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 69; } @@ -43593,7 +44779,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 9 || token === 163) { + if (token === 9 || token === 164) { var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { var lastCharIndex = tokenText.length - 1; @@ -43707,7 +44893,7 @@ var ts; } } function isKeyword(token) { - return token >= 70 && token <= 135; + return token >= 70 && token <= 136; } function classFromKind(token) { if (isKeyword(token)) { @@ -43723,7 +44909,7 @@ var ts; case 8: return 4; case 9: - case 163: + case 164: return 6; case 10: return 7; @@ -44114,12 +45300,12 @@ var ts; var index = 0; var checkOne = function () { if (matchSeq(seq)) { - var checkSpec = checkList[index]; + var checkSpec_1 = checkList[index]; index++; - if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) { - _this.syntacticCheck(checkSpec.fileName, checkSpec.project); + if (checkSpec_1.project.getSourceFileFromName(checkSpec_1.fileName, requireOpen)) { + _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); _this.immediateId = setImmediate(function () { - _this.semanticCheck(checkSpec.fileName, checkSpec.project); + _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); _this.immediateId = undefined; if (checkList.length > index) { _this.errorTimer = setTimeout(checkOne, followMs); @@ -44408,7 +45594,7 @@ var ts; }; var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); var hasIndent = 0; - var i, len; + var i = void 0, len = void 0; for (i = 0, len = lineText.length; i < len; i++) { if (lineText.charAt(i) == " ") { hasIndent++; @@ -44881,6 +46067,9 @@ var ts; LSHost.prototype.getScriptFileNames = function () { return this.roots.map(function (root) { return root.fileName; }); }; + LSHost.prototype.getScriptKind = function () { + return 0; + }; LSHost.prototype.getScriptVersion = function (filename) { return this.getScriptInfo(filename).svc.latestVersion().toString(); }; @@ -45482,7 +46671,7 @@ var ts; fileName = ts.normalizePath(fileName); var info = ts.lookUp(this.filenameToScriptInfo, fileName); if (!info) { - var content; + var content = void 0; if (this.host.fileExists(fileName)) { content = fileContent || this.host.readFile(fileName); } @@ -45512,9 +46701,13 @@ var ts; }; ProjectService.prototype.findConfigFile = function (searchPath) { while (true) { - var fileName = ts.combinePaths(searchPath, "tsconfig.json"); - if (this.host.fileExists(fileName)) { - return fileName; + var tsconfigFileName = ts.combinePaths(searchPath, "tsconfig.json"); + if (this.host.fileExists(tsconfigFileName)) { + return tsconfigFileName; + } + var jsconfigFileName = ts.combinePaths(searchPath, "jsconfig.json"); + if (this.host.fileExists(jsconfigFileName)) { + return jsconfigFileName; } var parentPath = ts.getDirectoryPath(searchPath); if (parentPath === searchPath) { @@ -45642,7 +46835,7 @@ var ts; return { succeeded: false, error: rawConfig.error }; } else { - var parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath); + var parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath, {}, configFilename); ts.Debug.assert(!!parsedCommandLine.fileNames); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; @@ -45666,22 +46859,22 @@ var ts; return error; } else { - var project = this.createProject(configFilename, projectOptions); + var project_1 = this.createProject(configFilename, projectOptions); for (var _i = 0, _b = projectOptions.files; _i < _b.length; _i++) { var rootFilename = _b[_i]; if (this.host.fileExists(rootFilename)) { var info = this.openFile(rootFilename, clientFileName == rootFilename); - project.addRoot(info); + project_1.addRoot(info); } else { return { errorMsg: "specified file " + rootFilename + " not found" }; } } - project.finishGraph(); - project.projectFileWatcher = this.host.watchFile(ts.toPath(configFilename, configFilename, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), function (_) { return _this.watchedProjectConfigFileChanged(project); }); + project_1.finishGraph(); + project_1.projectFileWatcher = this.host.watchFile(ts.toPath(configFilename, configFilename, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), function (_) { return _this.watchedProjectConfigFileChanged(project_1); }); this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename)); - project.directoryWatcher = this.host.watchDirectory(ts.getDirectoryPath(configFilename), function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, true); - return { success: true, project: project }; + project_1.directoryWatcher = this.host.watchDirectory(ts.getDirectoryPath(configFilename), function (path) { return _this.directoryWatchedForSourceFilesChanged(project_1, path); }, true); + return { success: true, project: project_1 }; } }; ProjectService.prototype.updateConfiguredProject = function (project) { @@ -45695,10 +46888,10 @@ var ts; return error; } else { - 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; }); + var oldFileNames_1 = project.compilerService.host.roots.map(function (info) { return info.fileName; }); + var newFileNames_1 = projectOptions.files; + var fileNamesToRemove = oldFileNames_1.filter(function (f) { return newFileNames_1.indexOf(f) < 0; }); + var fileNamesToAdd = newFileNames_1.filter(function (f) { return oldFileNames_1.indexOf(f) < 0; }); for (var _i = 0, fileNamesToRemove_1 = fileNamesToRemove; _i < fileNamesToRemove_1.length; _i++) { var fileName = fileNamesToRemove_1[_i]; var info = this.getScriptInfo(fileName); @@ -46229,7 +47422,7 @@ var ts; } } else { - var checkText; + var checkText = void 0; if (this.checkEdits) { checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); } @@ -46874,6 +48067,14 @@ var ts; var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0; + } + }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { return this.shimHost.getScriptVersion(fileName); }; @@ -47277,7 +48478,8 @@ var ts; errors: [realizeDiagnostic(result.error, "\r\n")] }; } - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); return { options: configFile.options, files: configFile.fileNames, @@ -47360,4 +48562,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "1.8"; +var toolsVersion = "1.9"; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 412f4e793b0..1ad5a4bc28d 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -160,169 +160,170 @@ declare namespace ts { IsKeyword = 124, ModuleKeyword = 125, NamespaceKeyword = 126, - RequireKeyword = 127, - NumberKeyword = 128, - SetKeyword = 129, - StringKeyword = 130, - SymbolKeyword = 131, - TypeKeyword = 132, - FromKeyword = 133, - GlobalKeyword = 134, - OfKeyword = 135, - QualifiedName = 136, - ComputedPropertyName = 137, - TypeParameter = 138, - Parameter = 139, - Decorator = 140, - PropertySignature = 141, - PropertyDeclaration = 142, - MethodSignature = 143, - MethodDeclaration = 144, - Constructor = 145, - GetAccessor = 146, - SetAccessor = 147, - CallSignature = 148, - ConstructSignature = 149, - IndexSignature = 150, - TypePredicate = 151, - TypeReference = 152, - FunctionType = 153, - ConstructorType = 154, - TypeQuery = 155, - TypeLiteral = 156, - ArrayType = 157, - TupleType = 158, - UnionType = 159, - IntersectionType = 160, - ParenthesizedType = 161, - ThisType = 162, - StringLiteralType = 163, - ObjectBindingPattern = 164, - ArrayBindingPattern = 165, - BindingElement = 166, - ArrayLiteralExpression = 167, - ObjectLiteralExpression = 168, - PropertyAccessExpression = 169, - ElementAccessExpression = 170, - CallExpression = 171, - NewExpression = 172, - TaggedTemplateExpression = 173, - TypeAssertionExpression = 174, - ParenthesizedExpression = 175, - FunctionExpression = 176, - ArrowFunction = 177, - DeleteExpression = 178, - TypeOfExpression = 179, - VoidExpression = 180, - AwaitExpression = 181, - PrefixUnaryExpression = 182, - PostfixUnaryExpression = 183, - BinaryExpression = 184, - ConditionalExpression = 185, - TemplateExpression = 186, - YieldExpression = 187, - SpreadElementExpression = 188, - ClassExpression = 189, - OmittedExpression = 190, - ExpressionWithTypeArguments = 191, - AsExpression = 192, - TemplateSpan = 193, - SemicolonClassElement = 194, - Block = 195, - VariableStatement = 196, - EmptyStatement = 197, - ExpressionStatement = 198, - IfStatement = 199, - DoStatement = 200, - WhileStatement = 201, - ForStatement = 202, - ForInStatement = 203, - ForOfStatement = 204, - ContinueStatement = 205, - BreakStatement = 206, - ReturnStatement = 207, - WithStatement = 208, - SwitchStatement = 209, - LabeledStatement = 210, - ThrowStatement = 211, - TryStatement = 212, - DebuggerStatement = 213, - VariableDeclaration = 214, - VariableDeclarationList = 215, - FunctionDeclaration = 216, - ClassDeclaration = 217, - InterfaceDeclaration = 218, - TypeAliasDeclaration = 219, - EnumDeclaration = 220, - ModuleDeclaration = 221, - ModuleBlock = 222, - CaseBlock = 223, - ImportEqualsDeclaration = 224, - ImportDeclaration = 225, - ImportClause = 226, - NamespaceImport = 227, - NamedImports = 228, - ImportSpecifier = 229, - ExportAssignment = 230, - ExportDeclaration = 231, - NamedExports = 232, - ExportSpecifier = 233, - MissingDeclaration = 234, - ExternalModuleReference = 235, - JsxElement = 236, - JsxSelfClosingElement = 237, - JsxOpeningElement = 238, - JsxText = 239, - JsxClosingElement = 240, - JsxAttribute = 241, - JsxSpreadAttribute = 242, - JsxExpression = 243, - CaseClause = 244, - DefaultClause = 245, - HeritageClause = 246, - CatchClause = 247, - PropertyAssignment = 248, - ShorthandPropertyAssignment = 249, - EnumMember = 250, - SourceFile = 251, - JSDocTypeExpression = 252, - JSDocAllType = 253, - JSDocUnknownType = 254, - JSDocArrayType = 255, - JSDocUnionType = 256, - JSDocTupleType = 257, - JSDocNullableType = 258, - JSDocNonNullableType = 259, - JSDocRecordType = 260, - JSDocRecordMember = 261, - JSDocTypeReference = 262, - JSDocOptionalType = 263, - JSDocFunctionType = 264, - JSDocVariadicType = 265, - JSDocConstructorType = 266, - JSDocThisType = 267, - JSDocComment = 268, - JSDocTag = 269, - JSDocParameterTag = 270, - JSDocReturnTag = 271, - JSDocTypeTag = 272, - JSDocTemplateTag = 273, - SyntaxList = 274, - Count = 275, + ReadonlyKeyword = 127, + RequireKeyword = 128, + NumberKeyword = 129, + SetKeyword = 130, + StringKeyword = 131, + SymbolKeyword = 132, + TypeKeyword = 133, + FromKeyword = 134, + GlobalKeyword = 135, + OfKeyword = 136, + QualifiedName = 137, + ComputedPropertyName = 138, + TypeParameter = 139, + Parameter = 140, + Decorator = 141, + PropertySignature = 142, + PropertyDeclaration = 143, + MethodSignature = 144, + MethodDeclaration = 145, + Constructor = 146, + GetAccessor = 147, + SetAccessor = 148, + CallSignature = 149, + ConstructSignature = 150, + IndexSignature = 151, + TypePredicate = 152, + TypeReference = 153, + FunctionType = 154, + ConstructorType = 155, + TypeQuery = 156, + TypeLiteral = 157, + ArrayType = 158, + TupleType = 159, + UnionType = 160, + IntersectionType = 161, + ParenthesizedType = 162, + ThisType = 163, + StringLiteralType = 164, + ObjectBindingPattern = 165, + ArrayBindingPattern = 166, + BindingElement = 167, + ArrayLiteralExpression = 168, + ObjectLiteralExpression = 169, + PropertyAccessExpression = 170, + ElementAccessExpression = 171, + CallExpression = 172, + NewExpression = 173, + TaggedTemplateExpression = 174, + TypeAssertionExpression = 175, + ParenthesizedExpression = 176, + FunctionExpression = 177, + ArrowFunction = 178, + DeleteExpression = 179, + TypeOfExpression = 180, + VoidExpression = 181, + AwaitExpression = 182, + PrefixUnaryExpression = 183, + PostfixUnaryExpression = 184, + BinaryExpression = 185, + ConditionalExpression = 186, + TemplateExpression = 187, + YieldExpression = 188, + SpreadElementExpression = 189, + ClassExpression = 190, + OmittedExpression = 191, + ExpressionWithTypeArguments = 192, + AsExpression = 193, + TemplateSpan = 194, + SemicolonClassElement = 195, + Block = 196, + VariableStatement = 197, + EmptyStatement = 198, + ExpressionStatement = 199, + IfStatement = 200, + DoStatement = 201, + WhileStatement = 202, + ForStatement = 203, + ForInStatement = 204, + ForOfStatement = 205, + ContinueStatement = 206, + BreakStatement = 207, + ReturnStatement = 208, + WithStatement = 209, + SwitchStatement = 210, + LabeledStatement = 211, + ThrowStatement = 212, + TryStatement = 213, + DebuggerStatement = 214, + VariableDeclaration = 215, + VariableDeclarationList = 216, + FunctionDeclaration = 217, + ClassDeclaration = 218, + InterfaceDeclaration = 219, + TypeAliasDeclaration = 220, + EnumDeclaration = 221, + ModuleDeclaration = 222, + ModuleBlock = 223, + CaseBlock = 224, + ImportEqualsDeclaration = 225, + ImportDeclaration = 226, + ImportClause = 227, + NamespaceImport = 228, + NamedImports = 229, + ImportSpecifier = 230, + ExportAssignment = 231, + ExportDeclaration = 232, + NamedExports = 233, + ExportSpecifier = 234, + MissingDeclaration = 235, + ExternalModuleReference = 236, + JsxElement = 237, + JsxSelfClosingElement = 238, + JsxOpeningElement = 239, + JsxText = 240, + JsxClosingElement = 241, + JsxAttribute = 242, + JsxSpreadAttribute = 243, + JsxExpression = 244, + CaseClause = 245, + DefaultClause = 246, + HeritageClause = 247, + CatchClause = 248, + PropertyAssignment = 249, + ShorthandPropertyAssignment = 250, + EnumMember = 251, + SourceFile = 252, + JSDocTypeExpression = 253, + JSDocAllType = 254, + JSDocUnknownType = 255, + JSDocArrayType = 256, + JSDocUnionType = 257, + JSDocTupleType = 258, + JSDocNullableType = 259, + JSDocNonNullableType = 260, + JSDocRecordType = 261, + JSDocRecordMember = 262, + JSDocTypeReference = 263, + JSDocOptionalType = 264, + JSDocFunctionType = 265, + JSDocVariadicType = 266, + JSDocConstructorType = 267, + JSDocThisType = 268, + JSDocComment = 269, + JSDocTag = 270, + JSDocParameterTag = 271, + JSDocReturnTag = 272, + JSDocTypeTag = 273, + JSDocTemplateTag = 274, + SyntaxList = 275, + Count = 276, FirstAssignment = 56, LastAssignment = 68, FirstReservedWord = 70, LastReservedWord = 105, FirstKeyword = 70, - LastKeyword = 135, + LastKeyword = 136, FirstFutureReservedWord = 106, LastFutureReservedWord = 114, - FirstTypeNode = 151, - LastTypeNode = 163, + FirstTypeNode = 152, + LastTypeNode = 164, FirstPunctuation = 15, LastPunctuation = 68, FirstToken = 0, - LastToken = 135, + LastToken = 136, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -331,40 +332,47 @@ declare namespace ts { LastTemplateToken = 14, FirstBinaryOperator = 25, LastBinaryOperator = 68, - FirstNode = 136, + FirstNode = 137, } enum NodeFlags { None = 0, - Export = 2, - Ambient = 4, - Public = 8, - Private = 16, - Protected = 32, - Static = 64, + Export = 1, + Ambient = 2, + Public = 4, + Private = 8, + Protected = 16, + Static = 32, + Readonly = 64, Abstract = 128, Async = 256, Default = 512, - MultiLine = 1024, - Synthetic = 2048, - DeclarationFile = 4096, - Let = 8192, - Const = 16384, - OctalLiteral = 32768, - Namespace = 65536, - ExportContext = 131072, - ContainsThis = 262144, - HasImplicitReturn = 524288, - HasExplicitReturn = 1048576, - GlobalAugmentation = 2097152, - HasClassExtends = 4194304, - HasDecorators = 8388608, - HasParamDecorators = 16777216, - HasAsyncFunctions = 33554432, - Modifier = 1022, - AccessibilityModifier = 56, - BlockScoped = 24576, - ReachabilityCheckFlags = 1572864, - EmitHelperFlags = 62914560, + Let = 1024, + Const = 2048, + Namespace = 4096, + ExportContext = 8192, + ContainsThis = 16384, + HasImplicitReturn = 32768, + HasExplicitReturn = 65536, + GlobalAugmentation = 131072, + HasClassExtends = 262144, + HasDecorators = 524288, + HasParamDecorators = 1048576, + HasAsyncFunctions = 2097152, + DisallowInContext = 4194304, + YieldContext = 8388608, + DecoratorContext = 16777216, + AwaitContext = 33554432, + ThisNodeHasError = 67108864, + JavaScriptFile = 134217728, + ThisNodeOrAnySubNodesHasError = 268435456, + HasAggregatedChildData = 536870912, + Modifier = 959, + AccessibilityModifier = 28, + BlockScoped = 3072, + ReachabilityCheckFlags = 98304, + EmitHelperFlags = 3932160, + ContextFlags = 62914560, + TypeExcludesFlags = 41943040, } enum JsxFlags { None = 0, @@ -372,10 +380,6 @@ declare namespace ts { IntrinsicNamedElement = 1, /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ IntrinsicIndexedElement = 2, - /** An element backed by a class, class-like, or function value */ - ValueElement = 4, - /** Element resolution failed */ - UnknownElement = 16, IntrinsicElement = 3, } interface Node extends TextRange { @@ -702,7 +706,7 @@ declare namespace ts { expression: LeftHandSideExpression; argumentExpression?: Expression; } - interface CallExpression extends LeftHandSideExpression { + interface CallExpression extends LeftHandSideExpression, Declaration { expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; @@ -1000,6 +1004,7 @@ declare namespace ts { interface JSDocThisType extends JSDocType { type: JSDocType; } + type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDocRecordMember extends PropertySignature { name: Identifier | LiteralExpression; type?: JSDocType; @@ -1040,6 +1045,7 @@ declare namespace ts { moduleName: string; referencedFiles: FileReference[]; languageVariant: LanguageVariant; + isDeclarationFile: boolean; /** * lib.d.ts should have a reference comment like * @@ -1133,6 +1139,7 @@ declare namespace ts { } interface EmitResult { emitSkipped: boolean; + /** Contains declaration emit diagnostics */ diagnostics: Diagnostic[]; } interface TypeChecker { @@ -1177,7 +1184,8 @@ declare namespace ts { buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1217,17 +1225,18 @@ declare namespace ts { This = 0, Identifier = 1, } - interface TypePredicate { + interface TypePredicateBase { kind: TypePredicateKind; type: Type; } - interface ThisTypePredicate extends TypePredicate { + interface ThisTypePredicate extends TypePredicateBase { _thisTypePredicateBrand: any; } - interface IdentifierTypePredicate extends TypePredicate { + interface IdentifierTypePredicate extends TypePredicateBase { parameterName: string; parameterIndex: number; } + type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -1328,7 +1337,6 @@ declare namespace ts { ESSymbol = 16777216, ThisType = 33554432, ObjectLiteralPatternWithComputedProperties = 67108864, - PredicateType = 134217728, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1341,9 +1349,6 @@ declare namespace ts { symbol?: Symbol; pattern?: DestructuringPattern; } - interface PredicateType extends Type { - predicate: ThisTypePredicate | IdentifierTypePredicate; - } interface StringLiteralType extends Type { text: string; } @@ -1359,8 +1364,8 @@ declare namespace ts { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; - declaredStringIndexType: Type; - declaredNumberIndexType: Type; + declaredStringIndexInfo: IndexInfo; + declaredNumberIndexInfo: IndexInfo; } interface TypeReference extends ObjectType { target: GenericType; @@ -1394,6 +1399,11 @@ declare namespace ts { String = 0, Number = 1, } + interface IndexInfo { + type: Type; + isReadonly: boolean; + declaration?: SignatureDeclaration; + } interface DiagnosticMessage { key: string; category: DiagnosticCategory; @@ -1429,6 +1439,9 @@ declare namespace ts { Classic = 1, NodeJs = 2, } + type RootPaths = string[]; + type PathSubstitutions = Map; + type TsConfigOnlyOptions = RootPaths | PathSubstitutions; interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -1476,9 +1489,14 @@ declare namespace ts { noImplicitReturns?: boolean; noFallthroughCasesInSwitch?: boolean; forceConsistentCasingInFileNames?: boolean; + baseUrl?: string; + paths?: PathSubstitutions; + rootDirs?: RootPaths; + traceModuleResolution?: boolean; allowSyntheticDefaultImports?: boolean; allowJs?: boolean; - [option: string]: string | number | boolean; + noImplicitUseStrict?: boolean; + [option: string]: string | number | boolean | TsConfigOnlyOptions; } enum ModuleKind { None = 0, @@ -1502,6 +1520,13 @@ declare namespace ts { line: number; character: number; } + enum ScriptKind { + Unknown = 0, + JS = 1, + JSX = 2, + TS = 3, + TSX = 4, + } enum ScriptTarget { ES3 = 0, ES5 = 1, @@ -1521,6 +1546,7 @@ declare namespace ts { interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string; + trace?(s: string): void; directoryExists?(directoryName: string): boolean; } interface ResolvedModule { @@ -1604,6 +1630,7 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; reScanJsxToken(): SyntaxKind; scanJsxToken(): SyntaxKind; + scanJSDocToken(): SyntaxKind; scan(): SyntaxKind; setText(text: string, start?: number, length?: number): void; setOnError(onError: ErrorCallback): void; @@ -1611,6 +1638,7 @@ declare namespace ts { setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; lookAhead(callback: () => T): T; + scanRange(start: number, length: number, callback: () => T): T; tryScan(callback: () => T): T; } function tokenToString(t: SyntaxKind): string; @@ -1661,7 +1689,7 @@ declare namespace ts { declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; + function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { @@ -1702,8 +1730,8 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions): ParsedCommandLine; - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string): ParsedCommandLine; + function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; @@ -1796,6 +1824,7 @@ declare namespace ts { getNewLine?(): string; getProjectVersion?(): string; getScriptFileNames(): string[]; + getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; getLocalizedDiagnosticMessages?(): any; @@ -2164,7 +2193,7 @@ declare namespace ts { * @parm version Current version of the file. Only used if the file was not found * in the registry and a new one was created. */ - acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; + acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; /** * Request an updated version of an already existing SourceFile with a given fileName * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile @@ -2177,7 +2206,7 @@ declare namespace ts { * @param scriptSnapshot Text of the file. * @param version Current version of the file. */ - updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; /** * Informs the DocumentRegistry that a file is not needed any longer. * @@ -2301,7 +2330,7 @@ declare namespace ts { } 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; + function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; diff --git a/lib/typescript.js b/lib/typescript.js index bbe9a4b07e3..8dafad54257 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -13,6 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +var __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 ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword @@ -156,190 +161,191 @@ var ts; SyntaxKind[SyntaxKind["IsKeyword"] = 124] = "IsKeyword"; SyntaxKind[SyntaxKind["ModuleKeyword"] = 125] = "ModuleKeyword"; SyntaxKind[SyntaxKind["NamespaceKeyword"] = 126] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 127] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 134] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 135] = "OfKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 127] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 128] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 129] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 130] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 131] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 132] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 133] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 134] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 135] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 136] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 136] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 137] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 137] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 138] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 138] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 139] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 140] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 139] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 140] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 141] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 142] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 143] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 144] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 145] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 146] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 147] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 148] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 149] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 150] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 142] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 143] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 144] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 145] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 146] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 147] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 148] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 149] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 150] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 151] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 151] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 152] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 153] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 154] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 155] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 156] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 157] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 158] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 159] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 160] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 161] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 162] = "ThisType"; - SyntaxKind[SyntaxKind["StringLiteralType"] = 163] = "StringLiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 152] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 153] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 154] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 155] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 156] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 157] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 158] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 159] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 160] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 161] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 162] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 163] = "ThisType"; + SyntaxKind[SyntaxKind["StringLiteralType"] = 164] = "StringLiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 164] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 165] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 166] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 165] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 166] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 167] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 167] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 168] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 169] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 170] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 171] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 172] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 173] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 174] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 175] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 176] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 177] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 178] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 179] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 180] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 181] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 182] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 183] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 184] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 185] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 186] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 187] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 188] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 189] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 190] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 191] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 192] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 168] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 169] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 170] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 171] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 172] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 173] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 174] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 175] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 176] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 177] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 178] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 179] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 180] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 181] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 182] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 183] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 184] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 185] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 187] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 188] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 189] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 190] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 191] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 192] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 193] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 193] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 194] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 194] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 195] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 195] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 196] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 197] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 198] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 199] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 200] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 201] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 202] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 203] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 204] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 205] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 206] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 207] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 208] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 209] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 210] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 211] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 212] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 213] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 214] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 215] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 216] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 217] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 218] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 219] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 220] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 221] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 222] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 223] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 224] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 225] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 226] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 227] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 228] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 229] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 230] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 231] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 232] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 233] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 234] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 196] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 197] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 198] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 199] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 200] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 201] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 202] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 203] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 204] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 205] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 206] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 207] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 208] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 209] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 210] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 211] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 212] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 213] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 214] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 215] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 216] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 217] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 218] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 219] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 220] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 221] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 222] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 223] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 224] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 225] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 226] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 227] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 228] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 229] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 230] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 231] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 232] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 233] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 234] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 235] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 235] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 236] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 236] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 237] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 238] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 239] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 240] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 241] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 242] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 243] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 237] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 238] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 239] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 240] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 241] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 242] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 243] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 244] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 244] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 245] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 246] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 247] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 245] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 246] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 247] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 248] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 248] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 249] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 249] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 250] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 250] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 251] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 251] = "SourceFile"; - // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 252] = "JSDocTypeExpression"; - // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 253] = "JSDocAllType"; - // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 254] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 255] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 256] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 257] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 258] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 259] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 260] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 261] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 262] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 263] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 264] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 265] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 266] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 267] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 268] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 269] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 270] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 271] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 272] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 273] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["SourceFile"] = 252] = "SourceFile"; + // JSDoc nodes + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 253] = "JSDocTypeExpression"; + // The * type + SyntaxKind[SyntaxKind["JSDocAllType"] = 254] = "JSDocAllType"; + // The ? type + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 255] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 256] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 257] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 258] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 259] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 260] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 261] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 262] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 263] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 264] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 265] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 266] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 267] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 268] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 269] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 270] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 271] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 272] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 273] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 274] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 274] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 275] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 275] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 276] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 135] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 136] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 163] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 152] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 164] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 135] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 136] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -348,83 +354,58 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 136] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 137] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Export"] = 2] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 4] = "Ambient"; - NodeFlags[NodeFlags["Public"] = 8] = "Public"; - NodeFlags[NodeFlags["Private"] = 16] = "Private"; - NodeFlags[NodeFlags["Protected"] = 32] = "Protected"; - NodeFlags[NodeFlags["Static"] = 64] = "Static"; + NodeFlags[NodeFlags["Export"] = 1] = "Export"; + NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; + NodeFlags[NodeFlags["Public"] = 4] = "Public"; + NodeFlags[NodeFlags["Private"] = 8] = "Private"; + NodeFlags[NodeFlags["Protected"] = 16] = "Protected"; + NodeFlags[NodeFlags["Static"] = 32] = "Static"; + NodeFlags[NodeFlags["Readonly"] = 64] = "Readonly"; NodeFlags[NodeFlags["Abstract"] = 128] = "Abstract"; NodeFlags[NodeFlags["Async"] = 256] = "Async"; NodeFlags[NodeFlags["Default"] = 512] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 1024] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 2048] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 4096] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 8192] = "Let"; - NodeFlags[NodeFlags["Const"] = 16384] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 32768] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 65536] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 131072] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 262144] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 524288] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 1048576] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 2097152] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasClassExtends"] = 4194304] = "HasClassExtends"; - NodeFlags[NodeFlags["HasDecorators"] = 8388608] = "HasDecorators"; - NodeFlags[NodeFlags["HasParamDecorators"] = 16777216] = "HasParamDecorators"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 33554432] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 1572864] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 62914560] = "EmitHelperFlags"; + NodeFlags[NodeFlags["Let"] = 1024] = "Let"; + NodeFlags[NodeFlags["Const"] = 2048] = "Const"; + NodeFlags[NodeFlags["Namespace"] = 4096] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 8192] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 16384] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 32768] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 65536] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 131072] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 262144] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 524288] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 1048576] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2097152] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4194304] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8388608] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16777216] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 33554432] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 67108864] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 134217728] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 268435456] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 536870912] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["Modifier"] = 959] = "Modifier"; + NodeFlags[NodeFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + NodeFlags[NodeFlags["BlockScoped"] = 3072] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 98304] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 3932160] = "EmitHelperFlags"; + // Parsing context flags + NodeFlags[NodeFlags["ContextFlags"] = 62914560] = "ContextFlags"; + // Exclude these flags when parsing a Type + NodeFlags[NodeFlags["TypeExcludesFlags"] = 41943040] = "TypeExcludesFlags"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; - /* @internal */ - (function (ParserContextFlags) { - ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; - // If this node was parsed in a context where 'in-expressions' are not allowed. - ParserContextFlags[ParserContextFlags["DisallowIn"] = 1] = "DisallowIn"; - // If this node was parsed in the 'yield' context created when parsing a generator. - ParserContextFlags[ParserContextFlags["Yield"] = 2] = "Yield"; - // If this node was parsed as part of a decorator - ParserContextFlags[ParserContextFlags["Decorator"] = 4] = "Decorator"; - // If this node was parsed in the 'await' context created when parsing an async function. - ParserContextFlags[ParserContextFlags["Await"] = 8] = "Await"; - // If the parser encountered an error when parsing the code that created this node. Note - // the parser only sets this directly on the node it creates right after encountering the - // error. - ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; - // This node was parsed in a JavaScript file and can be processed differently. For example - // its type can be specified usign a JSDoc comment. - ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 32] = "JavaScriptFile"; - // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; - // Exclude these flags when parsing a Type - ParserContextFlags[ParserContextFlags["TypeExcludesFlags"] = 10] = "TypeExcludesFlags"; - // Context flags computed by aggregating child flags upwards. - // Used during incremental parsing to determine if this node or any of its children had an - // error. Computed only once and then cached. - ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; - // Used to know if we've computed data from children and cached it in this node. - ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; - })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); - var ParserContextFlags = ts.ParserContextFlags; (function (JsxFlags) { JsxFlags[JsxFlags["None"] = 0] = "None"; /** An element from a named property of the JSX.IntrinsicElements interface */ JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; - /** An element backed by a class, class-like, or function value */ - JsxFlags[JsxFlags["ValueElement"] = 4] = "ValueElement"; - /** Element resolution failed */ - JsxFlags[JsxFlags["UnknownElement"] = 16] = "UnknownElement"; JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; })(ts.JsxFlags || (ts.JsxFlags = {})); var JsxFlags = ts.JsxFlags; @@ -594,13 +575,17 @@ var ts; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalArguments"] = 2048] = "LexicalArguments"; - NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 4096] = "CaptureArguments"; - // Values for enum members have been computed, and any errors have been reported for them. - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 8192] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 16384] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; - NodeCheckFlags[NodeCheckFlags["LoopWithBlockScopedBindingCapturedInFunction"] = 65536] = "LoopWithBlockScopedBindingCapturedInFunction"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); var NodeCheckFlags = ts.NodeCheckFlags; (function (TypeFlags) { @@ -636,7 +621,6 @@ var ts; TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; TypeFlags[TypeFlags["ObjectLiteralPatternWithComputedProperties"] = 67108864] = "ObjectLiteralPatternWithComputedProperties"; - TypeFlags[TypeFlags["PredicateType"] = 134217728] = "PredicateType"; /* @internal */ TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; /* @internal */ @@ -647,7 +631,7 @@ var ts; TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 140509184] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; })(ts.TypeFlags || (ts.TypeFlags = {})); @@ -707,6 +691,14 @@ var ts; NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; })(ts.NewLineKind || (ts.NewLineKind = {})); var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; @@ -1278,6 +1270,15 @@ var ts; }; } ts.createFileDiagnostic = createFileDiagnostic; + /* internal */ + function formatMessage(dummy, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); + } + return text; + } + ts.formatMessage = formatMessage; function createCompilerDiagnostic(message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 1) { @@ -1480,7 +1481,7 @@ var ts; } ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; function getNormalizedPathComponentsOfUrl(url) { - // Get root length of http://www.website.com/folder1/foler2/ + // Get root length of http://www.website.com/folder1/folder2/ // In this example the root is: http://www.website.com/ // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] var urlLength = url.length; @@ -1505,7 +1506,7 @@ var ts; var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); if (indexOfNextSlash !== -1) { // Found the "/" after the website.com so the root is length of http://www.website.com/ - // and get components afetr the root normally like any other folder components + // and get components after the root normally like any other folder components rootLength = indexOfNextSlash + 1; return normalizedPathComponents(url, rootLength); } @@ -1962,15 +1963,13 @@ var ts; } } } - /** - * @param watcherPath is the path from which the watcher is triggered. - */ function fileEventHandler(eventName, relativeFileName, baseDirPath) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" var filePath = typeof relativeFileName !== "string" ? undefined : ts.toPath(relativeFileName, baseDirPath, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); - if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) { + // Some applications save a working file via rename operations + if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks.contains(filePath)) { for (var _i = 0, _a = fileWatcherCallbacks.get(filePath); _i < _a.length; _i++) { var fileCallback = _a[_i]; fileCallback(filePath); @@ -2000,7 +1999,7 @@ var ts; // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { + if (!fileExists(fileName)) { return undefined; } var buffer = _fs.readFileSync(fileName); @@ -2046,6 +2045,29 @@ var ts; function getCanonicalPath(path) { return useCaseSensitiveFileNames ? path : path.toLowerCase(); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); + function fileSystemEntryExists(path, entryKind) { + try { + var stat = _fs.statSync(path); + switch (entryKind) { + case 0 /* File */: return stat.isFile(); + case 1 /* Directory */: return stat.isDirectory(); + } + } + catch (e) { + return false; + } + } + function fileExists(path) { + return fileSystemEntryExists(path, 0 /* File */); + } + function directoryExists(path) { + return fileSystemEntryExists(path, 1 /* Directory */); + } function readDirectory(path, extension, exclude) { var result = []; exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); @@ -2085,7 +2107,7 @@ var ts; readFile: readFile, writeFile: writeFile, watchFile: function (filePath, callback) { - // Node 4.0 stablized the `fs.watch` function on Windows which avoids polling + // Node 4.0 stabilized the `fs.watch` function on Windows which avoids polling // and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 // and https://github.com/Microsoft/TypeScript/issues/4643), therefore // if the current node.js version is newer than 4, use `fs.watch` instead. @@ -2119,12 +2141,8 @@ var ts; resolvePath: function (path) { return _path.resolve(path); }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, + fileExists: fileExists, + directoryExists: directoryExists, createDirectory: function (directoryName) { if (!this.directoryExists(directoryName)) { _fs.mkdirSync(directoryName); @@ -2214,6 +2232,7 @@ var ts; An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_a_type_annotation_1021", message: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_must_have_a_type_annotation_1022", message: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_type_must_be_string_or_number_1023", message: "An index signature parameter type must be 'string' or 'number'." }, + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: { code: 1024, category: ts.DiagnosticCategory.Error, key: "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", message: "'readonly' modifier can only appear on a property declaration or index signature." }, Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility_modifier_already_seen_1028", message: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "_0_modifier_must_precede_1_modifier_1029", message: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "_0_modifier_already_seen_1030", message: "'{0}' modifier already seen." }, @@ -2227,7 +2246,7 @@ var ts; _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_a_class_declaration_1041", message: "'{0}' modifier cannot be used with a class declaration." }, _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_here_1042", message: "'{0}' modifier cannot be used here." }, _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_data_property_1043", message: "'{0}' modifier cannot appear on a data property." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_element_1044", message: "'{0}' modifier cannot appear on a module element." }, + _0_modifier_cannot_appear_on_a_module_or_namespace_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", message: "'{0}' modifier cannot appear on a module or namespace element." }, A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", message: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", message: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_be_optional_1047", message: "A rest parameter cannot be optional." }, @@ -2246,8 +2265,11 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum_member_must_have_initializer_1061", message: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_namespace_1063", message: "An export assignment cannot be used in a namespace." }, + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { code: 1064, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", message: "The return type of an async function or method must be the global Promise type." }, In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", message: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", message: "Unexpected token. A constructor, method, accessor, or property was expected." }, + _0_modifier_cannot_appear_on_a_type_member: { code: 1070, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_type_member_1070", message: "'{0}' modifier cannot appear on a type member." }, + _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, @@ -2303,10 +2325,9 @@ var ts; String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String_literal_expected_1141", message: "String literal expected." }, Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line_break_not_permitted_here_1142", message: "Line break not permitted here." }, or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers_not_permitted_on_index_signature_members_1145", message: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." }, Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." }, - Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_optio_1148", message: "Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file." }, + Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting__1148", message: "Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" }, @@ -2366,7 +2387,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Speci_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_6_or_higher_1220", message: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators_are_not_allowed_in_an_ambient_context_1221", message: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An_overload_signature_cannot_be_declared_as_a_generator_1222", message: "An overload signature cannot be declared as a generator." }, @@ -2375,6 +2396,7 @@ var ts; Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, @@ -2388,7 +2410,7 @@ var ts; Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", message: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", message: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", message: "Unable to resolve signature of method decorator when called as an expression." }, - abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_or_method_declaration_1242", message: "'abstract' modifier can only appear on a class or method declaration." }, + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", message: "'abstract' modifier can only appear on a class, method, or property declaration." }, _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_1_modifier_1243", message: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract_methods_can_only_appear_within_an_abstract_class_1244", message: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", message: "Method '{0}' cannot have an implementation because it is marked abstract." }, @@ -2481,7 +2503,7 @@ var ts; get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", message: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_not_exported_2383", message: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_exported_or_non_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_non_exported_2383", message: "Overload signatures must all be exported or non-exported." }, Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", message: "Overload signatures must all be ambient or non-ambient." }, Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_public_private_or_protected_2385", message: "Overload signatures must all be public, private or protected." }, Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_optional_or_required_2386", message: "Overload signatures must all be optional or required." }, @@ -2514,7 +2536,6 @@ var ts; Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class_name_cannot_be_0_2414", message: "Class name cannot be '{0}'" }, Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_extends_base_class_1_2415", message: "Class '{0}' incorrectly extends base class '{1}'." }, Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", message: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0_2419", message: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_implements_interface_1_2420", message: "Class '{0}' incorrectly implements interface '{1}'." }, A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_implement_another_class_or_interface_2422", message: "A class may only implement another class or interface." }, Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, @@ -2522,7 +2543,7 @@ var ts; Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface_name_cannot_be_0_2427", message: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_interface_must_have_identical_type_parameters_2428", message: "All declarations of an interface must have identical type parameters." }, + All_declarations_of_0_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_type_parameters_2428", message: "All declarations of '{0}' must have identical type parameters." }, Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface_0_incorrectly_extends_interface_1_2430", message: "Interface '{0}' incorrectly extends interface '{1}'." }, Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum_name_cannot_be_0_2431", message: "Enum name cannot be '{0}'" }, In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", message: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, @@ -2542,8 +2563,8 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_2449", message: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_2450", message: "Left-hand side of assignment expression cannot be a constant." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -2576,8 +2597,8 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant_2485", message: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant_2486", message: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, @@ -2603,7 +2624,7 @@ var ts; Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", message: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base_constructors_must_all_have_the_same_return_type_2510", message: "Base constructors must all have the same return type." }, Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot_create_an_instance_of_the_abstract_class_0_2511", message: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_not_abstract_2512", message: "Overload signatures must all be abstract or not abstract." }, + Overload_signatures_must_all_be_abstract_or_non_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", message: "Overload signatures must all be abstract or non-abstract." }, Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", message: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes_containing_abstract_methods_must_be_marked_abstract_2514", message: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", message: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, @@ -2619,6 +2640,8 @@ var ts; A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", message: "A 'this' type is available only in a non-static member of a class or interface." }, The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary_2527", message: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A_module_cannot_have_multiple_default_exports_2528", message: "A module cannot have multiple default exports." }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { code: 2529, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions." }, + Property_0_is_incompatible_with_index_signature: { code: 2530, category: ts.DiagnosticCategory.Error, key: "Property_0_is_incompatible_with_index_signature_2530", message: "Property '{0}' is incompatible with index signature." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2648,6 +2671,12 @@ var ts; export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { code: 2669, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", message: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations." }, Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { code: 2670, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", message: "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context." }, + Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { code: 2671, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671", message: "Cannot augment module '{0}' because it resolves to a non-module entity." }, + Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: { code: 2672, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_a_0_constructor_type_to_a_1_constructor_type_2672", message: "Cannot assign a '{0}' constructor type to a '{1}' constructor type." }, + Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: { code: 2673, category: ts.DiagnosticCategory.Error, key: "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673", message: "Constructor of class '{0}' is private and only accessible within the class declaration." }, + Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: { code: 2674, category: ts.DiagnosticCategory.Error, key: "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674", message: "Constructor of class '{0}' is protected and only accessible within the class declaration." }, + Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: { code: 2675, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_a_class_0_Class_constructor_is_marked_as_private_2675", message: "Cannot extend a class '{0}'. Class constructor is marked as private." }, + Accessors_must_both_be_abstract_or_non_abstract: { code: 2676, category: ts.DiagnosticCategory.Error, key: "Accessors_must_both_be_abstract_or_non_abstract_2676", message: "Accessors must both be abstract or non-abstract." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2736,7 +2765,10 @@ var ts; Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { code: 5056, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056", message: "Cannot write file '{0}' because it would be overwritten by multiple input files." }, Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { code: 5057, category: ts.DiagnosticCategory.Error, key: "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057", message: "Cannot find a tsconfig.json file at the specified directory: '{0}'" }, The_specified_path_does_not_exist_Colon_0: { code: 5058, category: ts.DiagnosticCategory.Error, key: "The_specified_path_does_not_exist_Colon_0_5058", message: "The specified path does not exist: '{0}'" }, - Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier: { code: 5059, category: ts.DiagnosticCategory.Error, key: "Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", message: "Invalide value for '--reactNamespace'. '{0}' is not a valid identifier." }, + Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: { code: 5059, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", message: "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier." }, + Option_paths_cannot_be_used_without_specifying_baseUrl_option: { code: 5060, category: ts.DiagnosticCategory.Error, key: "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", message: "Option 'paths' cannot be used without specifying '--baseUrl' option." }, + Pattern_0_can_have_at_most_one_Asterisk_character: { code: 5061, category: ts.DiagnosticCategory.Error, key: "Pattern_0_can_have_at_most_one_Asterisk_character_5061", message: "Pattern '{0}' can have at most one '*' character" }, + Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { code: 5062, category: ts.DiagnosticCategory.Error, key: "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", message: "Substitution '{0}' in pattern '{1}' in can have at most one '*' character" }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, 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_6003", message: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2770,7 +2802,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated_quoted_string_in_response_file_0_6045", message: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'none'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument_for_target_option_must_be_ES3_ES5_or_ES2015_6047", message: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", message: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported_locale_0_6049", message: "Unsupported locale '{0}'." }, @@ -2787,6 +2819,7 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, + Option_0_can_only_be_specified_in_tsconfig_json_file: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", message: "Option '{0}' can only be specified in 'tsconfig.json' file." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "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_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -2803,8 +2836,36 @@ var ts; Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "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_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, - Allow_javascript_files_to_be_compiled: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6083", message: "Allow javascript files to be compiled." }, + Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specifies the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Enable_tracing_of_the_module_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_module_resolution_process_6085", message: "Enable tracing of the module resolution process." }, + Resolving_module_0_from_1: { code: 6086, category: ts.DiagnosticCategory.Message, key: "Resolving_module_0_from_1_6086", message: "======== Resolving module '{0}' from '{1}'. ========" }, + Explicitly_specified_module_resolution_kind_Colon_0: { code: 6087, category: ts.DiagnosticCategory.Message, key: "Explicitly_specified_module_resolution_kind_Colon_0_6087", message: "Explicitly specified module resolution kind: '{0}'." }, + Module_resolution_kind_is_not_specified_using_0: { code: 6088, category: ts.DiagnosticCategory.Message, key: "Module_resolution_kind_is_not_specified_using_0_6088", message: "Module resolution kind is not specified, using '{0}'." }, + Module_name_0_was_successfully_resolved_to_1: { code: 6089, category: ts.DiagnosticCategory.Message, key: "Module_name_0_was_successfully_resolved_to_1_6089", message: "======== Module name '{0}' was successfully resolved to '{1}'. ========" }, + Module_name_0_was_not_resolved: { code: 6090, category: ts.DiagnosticCategory.Message, key: "Module_name_0_was_not_resolved_6090", message: "======== Module name '{0}' was not resolved. ========" }, + paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: { code: 6091, category: ts.DiagnosticCategory.Message, key: "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091", message: "'paths' option is specified, looking for a pattern to match module name '{0}'." }, + Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, + Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, + Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, + File_0_exist_use_it_as_a_module_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_module_resolution_result_6097", message: "File '{0}' exist - use it as a module resolution result." }, + Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, + package_json_does_not_have_typings_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_typings_field_6100", message: "'package.json' does not have 'typings' field." }, + package_json_has_typings_field_0_that_references_1: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_typings_field_0_that_references_1_6101", message: "'package.json' has 'typings' field '{0}' that references '{1}'." }, + Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, + Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, + Checking_if_0_is_the_longest_matching_prefix_for_1_2: { code: 6104, category: ts.DiagnosticCategory.Message, key: "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104", message: "Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'." }, + Expected_type_of_typings_field_in_package_json_to_be_string_got_0: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_typings_field_in_package_json_to_be_string_got_0_6105", message: "Expected type of 'typings' field in 'package.json' to be 'string', got '{0}'." }, + baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: { code: 6106, category: ts.DiagnosticCategory.Message, key: "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106", message: "'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'" }, + rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: { code: 6107, category: ts.DiagnosticCategory.Message, key: "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107", message: "'rootDirs' option is set, using it to resolve relative module name '{0}'" }, + Longest_matching_prefix_for_0_is_1: { code: 6108, category: ts.DiagnosticCategory.Message, key: "Longest_matching_prefix_for_0_is_1_6108", message: "Longest matching prefix for '{0}' is '{1}'" }, + Loading_0_from_the_root_dir_1_candidate_location_2: { code: 6109, category: ts.DiagnosticCategory.Message, key: "Loading_0_from_the_root_dir_1_candidate_location_2_6109", message: "Loading '{0}' from the root dir '{1}', candidate location '{2}'" }, + Trying_other_entries_in_rootDirs: { code: 6110, category: ts.DiagnosticCategory.Message, key: "Trying_other_entries_in_rootDirs_6110", message: "Trying other entries in 'rootDirs'" }, + Module_resolution_using_rootDirs_has_failed: { code: 6111, category: ts.DiagnosticCategory.Message, key: "Module_resolution_using_rootDirs_has_failed_6111", message: "Module resolution using 'rootDirs' has failed" }, + Do_not_emit_use_strict_directives_in_module_output: { code: 6112, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_use_strict_directives_in_module_output_6112", message: "Do not emit 'use strict' directives in module output." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -2843,7 +2904,6 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "property_declarations_can_only_be_used_in_a_ts_file_8014", message: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "enum_declarations_can_only_be_used_in_a_ts_file_8015", message: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", message: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "decorators_can_only_be_used_in_a_ts_file_8017", message: "'decorators' can only be used in a .ts file." }, Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -2854,7 +2914,8 @@ var ts; 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_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", message: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, - JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." } + JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." }, + super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." } }; })(ts || (ts = {})); /// @@ -2890,7 +2951,7 @@ var ts; "false": 84 /* FalseKeyword */, "finally": 85 /* FinallyKeyword */, "for": 86 /* ForKeyword */, - "from": 133 /* FromKeyword */, + "from": 134 /* FromKeyword */, "function": 87 /* FunctionKeyword */, "get": 123 /* GetKeyword */, "if": 88 /* IfKeyword */, @@ -2905,25 +2966,26 @@ var ts; "namespace": 126 /* NamespaceKeyword */, "new": 92 /* NewKeyword */, "null": 93 /* NullKeyword */, - "number": 128 /* NumberKeyword */, + "number": 129 /* NumberKeyword */, "package": 109 /* PackageKeyword */, "private": 110 /* PrivateKeyword */, "protected": 111 /* ProtectedKeyword */, "public": 112 /* PublicKeyword */, - "require": 127 /* RequireKeyword */, - "global": 134 /* GlobalKeyword */, + "readonly": 127 /* ReadonlyKeyword */, + "require": 128 /* RequireKeyword */, + "global": 135 /* GlobalKeyword */, "return": 94 /* ReturnKeyword */, - "set": 129 /* SetKeyword */, + "set": 130 /* SetKeyword */, "static": 113 /* StaticKeyword */, - "string": 130 /* StringKeyword */, + "string": 131 /* StringKeyword */, "super": 95 /* SuperKeyword */, "switch": 96 /* SwitchKeyword */, - "symbol": 131 /* SymbolKeyword */, + "symbol": 132 /* SymbolKeyword */, "this": 97 /* ThisKeyword */, "throw": 98 /* ThrowKeyword */, "true": 99 /* TrueKeyword */, "try": 100 /* TryKeyword */, - "type": 132 /* TypeKeyword */, + "type": 133 /* TypeKeyword */, "typeof": 101 /* TypeOfKeyword */, "var": 102 /* VarKeyword */, "void": 103 /* VoidKeyword */, @@ -2932,7 +2994,7 @@ var ts; "yield": 114 /* YieldKeyword */, "async": 118 /* AsyncKeyword */, "await": 119 /* AwaitKeyword */, - "of": 135 /* OfKeyword */, + "of": 136 /* OfKeyword */, "{": 15 /* OpenBraceToken */, "}": 16 /* CloseBraceToken */, "(": 17 /* OpenParenToken */, @@ -3304,7 +3366,7 @@ var ts; } ts.skipTrivia = skipTrivia; // All conflict markers consist of the same character repeated seven times. If it is - // a <<<<<<< or >>>>>>> marker then it is also followd by a space. + // a <<<<<<< or >>>>>>> marker then it is also followed by a space. var mergeConflictMarkerLength = "<<<<<<<".length; function isConflictMarkerTrivia(text, pos) { ts.Debug.assert(pos >= 0); @@ -3336,7 +3398,7 @@ var ts; } else { ts.Debug.assert(ch === 61 /* equals */); - // Consume everything from the start of the mid-conlict marker to the start of the next + // Consume everything from the start of the mid-conflict marker to the start of the next // end-conflict marker. while (pos < len) { var ch_1 = text.charCodeAt(pos); @@ -3519,6 +3581,7 @@ var ts; scanJsxIdentifier: scanJsxIdentifier, reScanJsxToken: reScanJsxToken, scanJsxToken: scanJsxToken, + scanJSDocToken: scanJSDocToken, scan: scan, setText: setText, setScriptTarget: setScriptTarget, @@ -3526,7 +3589,8 @@ var ts; setOnError: setOnError, setTextPos: setTextPos, tryScan: tryScan, - lookAhead: lookAhead + lookAhead: lookAhead, + scanRange: scanRange }; function error(message, length) { if (onError) { @@ -4348,7 +4412,7 @@ var ts; break; } } - return token = 239 /* JsxText */; + return token = 240 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -4368,6 +4432,55 @@ var ts; } return token; } + function scanJSDocToken() { + if (pos >= end) { + return token = 1 /* EndOfFileToken */; + } + startPos = pos; + // Eat leading whitespace + var ch = text.charCodeAt(pos); + while (pos < end) { + ch = text.charCodeAt(pos); + if (isWhiteSpace(ch)) { + pos++; + } + else { + break; + } + } + tokenPos = pos; + switch (ch) { + case 64 /* at */: + return pos += 1, token = 55 /* AtToken */; + case 10 /* lineFeed */: + case 13 /* carriageReturn */: + return pos += 1, token = 4 /* NewLineTrivia */; + case 42 /* asterisk */: + return pos += 1, token = 37 /* AsteriskToken */; + case 123 /* openBrace */: + return pos += 1, token = 15 /* OpenBraceToken */; + case 125 /* closeBrace */: + return pos += 1, token = 16 /* CloseBraceToken */; + case 91 /* openBracket */: + return pos += 1, token = 19 /* OpenBracketToken */; + case 93 /* closeBracket */: + return pos += 1, token = 20 /* CloseBracketToken */; + case 61 /* equals */: + return pos += 1, token = 56 /* EqualsToken */; + case 44 /* comma */: + return pos += 1, token = 24 /* CommaToken */; + } + if (isIdentifierStart(ch, 2 /* Latest */)) { + pos++; + while (isIdentifierPart(text.charCodeAt(pos), 2 /* Latest */) && pos < end) { + pos++; + } + return token = 69 /* Identifier */; + } + else { + return pos += 1, token = 0 /* Unknown */; + } + } function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; @@ -4388,6 +4501,29 @@ var ts; } return result; } + function scanRange(start, length, callback) { + var saveEnd = end; + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var savePrecedingLineBreak = precedingLineBreak; + var saveTokenValue = tokenValue; + var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; + var saveTokenIsUnterminated = tokenIsUnterminated; + setText(text, start, length); + var result = callback(); + end = saveEnd; + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + precedingLineBreak = savePrecedingLineBreak; + tokenValue = saveTokenValue; + hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; + tokenIsUnterminated = saveTokenIsUnterminated; + return result; + } function lookAhead(callback) { return speculationHelper(callback, /*isLookahead*/ true); } @@ -4443,10 +4579,10 @@ var ts; var stringWriters = []; function getSingleLineStringWriter() { if (stringWriters.length === 0) { - var str = ""; - var writeText = function (text) { return str += text; }; + var str_1 = ""; + var writeText = function (text) { return str_1 += text; }; return { - string: function () { return str; }, + string: function () { return str_1; }, writeKeyword: writeText, writeOperator: writeText, writePunctuation: writeText, @@ -4456,10 +4592,10 @@ var ts; writeSymbol: writeText, // Completely ignore indentation for string writers. And map newlines to // a single space. - writeLine: function () { return str += " "; }, + writeLine: function () { return str_1 += " "; }, increaseIndent: function () { }, decreaseIndent: function () { }, - clear: function () { return str = ""; }, + clear: function () { return str_1 = ""; }, trackSymbol: function () { }, reportInaccessibleThisError: function () { } }; @@ -4510,33 +4646,45 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 64 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 268435456 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 128 /* HasAggregatedChildData */)) { + if (!(node.flags & 536870912 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 67108864 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 64 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 268435456 /* ThisNodeOrAnySubNodesHasError */; } - // Also mark that we've propogated the child information to this node. This way we can + // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.parserContextFlags |= 128 /* HasAggregatedChildData */; + node.flags |= 536870912 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 251 /* SourceFile */) { + while (node && node.kind !== 252 /* SourceFile */) { node = node.parent; } return node; } ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 196 /* Block */: + case 224 /* CaseBlock */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; function getStartPositionOfLine(line, sourceFile) { ts.Debug.assert(line >= 0); return ts.getLineStarts(sourceFile)[line]; @@ -4630,17 +4778,24 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 24576 /* BlockScoped */) !== 0 || + return (getCombinedNodeFlags(declaration) & 3072 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 221 /* ModuleDeclaration */ && + return node && node.kind === 222 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; + function isBlockScopedContainerTopLevel(node) { + return node.kind === 252 /* SourceFile */ || + node.kind === 222 /* ModuleDeclaration */ || + isFunctionLike(node) || + isFunctionBlock(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 2097152 /* GlobalAugmentation */); + return !!(module.flags & 131072 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -4651,9 +4806,9 @@ var ts; return false; } switch (node.parent.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: return isExternalModule(node.parent); - case 222 /* ModuleBlock */: + case 223 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); } return false; @@ -4668,15 +4823,15 @@ var ts; return current; } switch (current.kind) { - case 251 /* SourceFile */: - case 223 /* CaseBlock */: - case 247 /* CatchClause */: - case 221 /* ModuleDeclaration */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 252 /* SourceFile */: + case 224 /* CaseBlock */: + case 248 /* CatchClause */: + case 222 /* ModuleDeclaration */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: return current; - case 195 /* Block */: + case 196 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4689,9 +4844,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 214 /* VariableDeclaration */ && + declaration.kind === 215 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 247 /* CatchClause */; + declaration.parent.kind === 248 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4730,7 +4885,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 251 /* SourceFile */: + case 252 /* 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 @@ -4739,18 +4894,20 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: - case 221 /* ModuleDeclaration */: - case 220 /* EnumDeclaration */: - case 250 /* EnumMember */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 144 /* MethodDeclaration */: - case 219 /* TypeAliasDeclaration */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: + case 222 /* ModuleDeclaration */: + case 221 /* EnumDeclaration */: + case 251 /* EnumMember */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 220 /* TypeAliasDeclaration */: errorNode = node.name; break; } @@ -4774,15 +4931,15 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { - return (file.flags & 4096 /* DeclarationFile */) !== 0; + return file.isDeclarationFile; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 220 /* EnumDeclaration */ && isConst(node); + return node.kind === 221 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 166 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 167 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4797,29 +4954,33 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 214 /* VariableDeclaration */) { + if (node.kind === 215 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 215 /* VariableDeclarationList */) { + if (node && node.kind === 216 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 196 /* VariableStatement */) { + if (node && node.kind === 197 /* VariableStatement */) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 16384 /* Const */); + return !!(getCombinedNodeFlags(node) & 2048 /* Const */); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 8192 /* Let */); + return !!(getCombinedNodeFlags(node) & 1024 /* Let */); } ts.isLet = isLet; + function isSuperCallExpression(n) { + return n.kind === 172 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + } + ts.isSuperCallExpression = isSuperCallExpression; function isPrologueDirective(node) { - return node.kind === 198 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 199 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -4835,7 +4996,7 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 139 /* Parameter */ || node.kind === 138 /* TypeParameter */) ? + var commentRanges = (node.kind === 140 /* Parameter */ || node.kind === 139 /* TypeParameter */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -4850,37 +5011,37 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 163 /* LastTypeNode */) { + if (152 /* FirstTypeNode */ <= node.kind && node.kind <= 164 /* LastTypeNode */) { return true; } switch (node.kind) { case 117 /* AnyKeyword */: - case 128 /* NumberKeyword */: - case 130 /* StringKeyword */: + case 129 /* NumberKeyword */: + case 131 /* StringKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: return true; case 103 /* VoidKeyword */: - return node.parent.kind !== 180 /* VoidExpression */; - case 191 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 181 /* VoidExpression */; + case 192 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 69 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 137 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 170 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 136 /* QualifiedName */: - case 169 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 137 /* QualifiedName */ || node.kind === 170 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 137 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: case 97 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 155 /* TypeQuery */) { + if (parent_1.kind === 156 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -4889,38 +5050,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 (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 163 /* LastTypeNode */) { + if (152 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 164 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: return node === parent_1.constraint; - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 139 /* Parameter */: - case 214 /* VariableDeclaration */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 140 /* Parameter */: + case 215 /* VariableDeclaration */: return node === parent_1.type; - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 145 /* Constructor */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 146 /* Constructor */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return node === parent_1.type; - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: return node === parent_1.type; - case 174 /* TypeAssertionExpression */: + case 175 /* TypeAssertionExpression */: return node === parent_1.type; - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -4934,23 +5095,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: return visitor(node); - case 223 /* CaseBlock */: - case 195 /* Block */: - case 199 /* IfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 208 /* WithStatement */: - case 209 /* SwitchStatement */: - case 244 /* CaseClause */: - case 245 /* DefaultClause */: - case 210 /* LabeledStatement */: - case 212 /* TryStatement */: - case 247 /* CatchClause */: + case 224 /* CaseBlock */: + case 196 /* Block */: + case 200 /* IfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 209 /* WithStatement */: + case 210 /* SwitchStatement */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: + case 211 /* LabeledStatement */: + case 213 /* TryStatement */: + case 248 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4960,18 +5121,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 220 /* EnumDeclaration */: - case 218 /* InterfaceDeclaration */: - case 221 /* ModuleDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 221 /* EnumDeclaration */: + case 219 /* InterfaceDeclaration */: + case 222 /* ModuleDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 218 /* ClassDeclaration */: + case 190 /* 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. @@ -4979,7 +5140,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 137 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 138 /* 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); @@ -4998,14 +5159,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 166 /* BindingElement */: - case 250 /* EnumMember */: - case 139 /* Parameter */: - case 248 /* PropertyAssignment */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 249 /* ShorthandPropertyAssignment */: - case 214 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 251 /* EnumMember */: + case 140 /* Parameter */: + case 249 /* PropertyAssignment */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 250 /* ShorthandPropertyAssignment */: + case 215 /* VariableDeclaration */: return true; } } @@ -5013,11 +5174,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 146 /* GetAccessor */ || node.kind === 147 /* SetAccessor */); + return node && (node.kind === 147 /* GetAccessor */ || node.kind === 148 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 217 /* ClassDeclaration */ || node.kind === 189 /* ClassExpression */); + return node && (node.kind === 218 /* ClassDeclaration */ || node.kind === 190 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5026,32 +5187,32 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 145 /* Constructor */: - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 146 /* Constructor */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: return true; } } ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: return true; } return false; @@ -5059,30 +5220,34 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: return true; - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 195 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 196 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 144 /* MethodDeclaration */ && node.parent.kind === 168 /* ObjectLiteralExpression */; + return node && node.kind === 145 /* MethodDeclaration */ && node.parent.kind === 169 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1 /* Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0 /* This */; + } + ts.isThisTypePredicate = isThisTypePredicate; function getContainingFunction(node) { while (true) { node = node.parent; @@ -5108,7 +5273,7 @@ var ts; return undefined; } switch (node.kind) { - case 137 /* ComputedPropertyName */: + case 138 /* 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 @@ -5123,9 +5288,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 140 /* Decorator */: + case 141 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 139 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 140 /* 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; @@ -5136,26 +5301,26 @@ var ts; node = node.parent; } break; - case 177 /* ArrowFunction */: + case 178 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 221 /* ModuleDeclaration */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 220 /* EnumDeclaration */: - case 251 /* SourceFile */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 222 /* ModuleDeclaration */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 221 /* EnumDeclaration */: + case 252 /* SourceFile */: return node; } } @@ -5176,26 +5341,26 @@ var ts; return node; } switch (node.kind) { - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: node = node.parent; break; - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return node; - case 140 /* Decorator */: + case 141 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 139 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 140 /* 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; @@ -5210,15 +5375,24 @@ var ts; } } ts.getSuperContainer = getSuperContainer; + /** + * Determines whether a node is a property or element access expression for super. + */ + function isSuperPropertyOrElementAccess(node) { + return (node.kind === 170 /* PropertyAccessExpression */ + || node.kind === 171 /* ElementAccessExpression */) + && node.expression.kind === 95 /* SuperKeyword */; + } + ts.isSuperPropertyOrElementAccess = isSuperPropertyOrElementAccess; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 152 /* TypeReference */: + case 153 /* TypeReference */: return node.typeName; - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return node.expression; case 69 /* Identifier */: - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return node; } } @@ -5226,7 +5400,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 173 /* TaggedTemplateExpression */) { + if (node.kind === 174 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5235,25 +5409,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: // classes are valid targets return true; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 217 /* ClassDeclaration */; - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 144 /* MethodDeclaration */: + return node.parent.kind === 218 /* ClassDeclaration */; + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 145 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 217 /* ClassDeclaration */; - case 139 /* Parameter */: + && node.parent.kind === 218 /* ClassDeclaration */; + case 140 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return node.parent.body !== undefined - && (node.parent.kind === 145 /* Constructor */ - || node.parent.kind === 144 /* MethodDeclaration */ - || node.parent.kind === 147 /* SetAccessor */) - && node.parent.parent.kind === 217 /* ClassDeclaration */; + && (node.parent.kind === 146 /* Constructor */ + || node.parent.kind === 145 /* MethodDeclaration */ + || node.parent.kind === 148 /* SetAccessor */) + && node.parent.parent.kind === 218 /* ClassDeclaration */; } return false; } @@ -5264,11 +5438,11 @@ var ts; } ts.nodeIsDecorated = nodeIsDecorated; function isPropertyAccessExpression(node) { - return node.kind === 169 /* PropertyAccessExpression */; + return node.kind === 170 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 170 /* ElementAccessExpression */; + return node.kind === 171 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { @@ -5278,42 +5452,42 @@ var ts; case 99 /* TrueKeyword */: case 84 /* FalseKeyword */: case 10 /* RegularExpressionLiteral */: - case 167 /* ArrayLiteralExpression */: - case 168 /* ObjectLiteralExpression */: - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 173 /* TaggedTemplateExpression */: - case 192 /* AsExpression */: - case 174 /* TypeAssertionExpression */: - case 175 /* ParenthesizedExpression */: - case 176 /* FunctionExpression */: - case 189 /* ClassExpression */: - case 177 /* ArrowFunction */: - case 180 /* VoidExpression */: - case 178 /* DeleteExpression */: - case 179 /* TypeOfExpression */: - case 182 /* PrefixUnaryExpression */: - case 183 /* PostfixUnaryExpression */: - case 184 /* BinaryExpression */: - case 185 /* ConditionalExpression */: - case 188 /* SpreadElementExpression */: - case 186 /* TemplateExpression */: + case 168 /* ArrayLiteralExpression */: + case 169 /* ObjectLiteralExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 174 /* TaggedTemplateExpression */: + case 193 /* AsExpression */: + case 175 /* TypeAssertionExpression */: + case 176 /* ParenthesizedExpression */: + case 177 /* FunctionExpression */: + case 190 /* ClassExpression */: + case 178 /* ArrowFunction */: + case 181 /* VoidExpression */: + case 179 /* DeleteExpression */: + case 180 /* TypeOfExpression */: + case 183 /* PrefixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: + case 185 /* BinaryExpression */: + case 186 /* ConditionalExpression */: + case 189 /* SpreadElementExpression */: + case 187 /* TemplateExpression */: case 11 /* NoSubstitutionTemplateLiteral */: - case 190 /* OmittedExpression */: - case 236 /* JsxElement */: - case 237 /* JsxSelfClosingElement */: - case 187 /* YieldExpression */: - case 181 /* AwaitExpression */: + case 191 /* OmittedExpression */: + case 237 /* JsxElement */: + case 238 /* JsxSelfClosingElement */: + case 188 /* YieldExpression */: + case 182 /* AwaitExpression */: return true; - case 136 /* QualifiedName */: - while (node.parent.kind === 136 /* QualifiedName */) { + case 137 /* QualifiedName */: + while (node.parent.kind === 137 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 155 /* TypeQuery */; + return node.parent.kind === 156 /* TypeQuery */; case 69 /* Identifier */: - if (node.parent.kind === 155 /* TypeQuery */) { + if (node.parent.kind === 156 /* TypeQuery */) { return true; } // fall through @@ -5322,47 +5496,47 @@ var ts; case 97 /* ThisKeyword */: var parent_2 = node.parent; switch (parent_2.kind) { - case 214 /* VariableDeclaration */: - case 139 /* Parameter */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 250 /* EnumMember */: - case 248 /* PropertyAssignment */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 140 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 251 /* EnumMember */: + case 249 /* PropertyAssignment */: + case 167 /* BindingElement */: return parent_2.initializer === node; - case 198 /* ExpressionStatement */: - case 199 /* IfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 207 /* ReturnStatement */: - case 208 /* WithStatement */: - case 209 /* SwitchStatement */: - case 244 /* CaseClause */: - case 211 /* ThrowStatement */: - case 209 /* SwitchStatement */: + case 199 /* ExpressionStatement */: + case 200 /* IfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 208 /* ReturnStatement */: + case 209 /* WithStatement */: + case 210 /* SwitchStatement */: + case 245 /* CaseClause */: + case 212 /* ThrowStatement */: + case 210 /* SwitchStatement */: return parent_2.expression === node; - case 202 /* ForStatement */: + case 203 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 215 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 216 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 215 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 216 /* VariableDeclarationList */) || forInStatement.expression === node; - case 174 /* TypeAssertionExpression */: - case 192 /* AsExpression */: + case 175 /* TypeAssertionExpression */: + case 193 /* AsExpression */: return node === parent_2.expression; - case 193 /* TemplateSpan */: + case 194 /* TemplateSpan */: return node === parent_2.expression; - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: return node === parent_2.expression; - case 140 /* Decorator */: - case 243 /* JsxExpression */: - case 242 /* JsxSpreadAttribute */: + case 141 /* Decorator */: + case 244 /* JsxExpression */: + case 243 /* JsxSpreadAttribute */: return true; - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5386,7 +5560,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */; + return node.kind === 225 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 236 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5395,7 +5569,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 235 /* ExternalModuleReference */; + return node.kind === 225 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 236 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5403,31 +5577,31 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.parserContextFlags & 32 /* JavaScriptFile */); + return node && !!(node.flags & 134217728 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; /** * Returns true if the node is a CallExpression to the identifier 'require' with - * exactly one string literal argument. + * exactly one argument. * This function does not test if the node is in a JavaScript file or not. */ - function isRequireCall(expression) { + function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - return expression.kind === 171 /* CallExpression */ && + var isRequire = expression.kind === 172 /* CallExpression */ && expression.expression.kind === 69 /* Identifier */ && expression.expression.text === "require" && - expression.arguments.length === 1 && - expression.arguments[0].kind === 9 /* StringLiteral */; + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9 /* StringLiteral */); } ts.isRequireCall = isRequireCall; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getSpecialPropertyAssignmentKind(expression) { - if (expression.kind !== 184 /* BinaryExpression */) { + if (expression.kind !== 185 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 169 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 170 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -5445,7 +5619,7 @@ var ts; else if (lhs.expression.kind === 97 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 169 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 170 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 69 /* Identifier */ && innerPropertyAccess.name.text === "prototype") { @@ -5456,19 +5630,19 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 225 /* ImportDeclaration */) { + if (node.kind === 226 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 224 /* ImportEqualsDeclaration */) { + if (node.kind === 225 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 235 /* ExternalModuleReference */) { + if (reference.kind === 236 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 231 /* ExportDeclaration */) { + if (node.kind === 232 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 221 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 222 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } @@ -5476,13 +5650,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 139 /* Parameter */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 249 /* ShorthandPropertyAssignment */: - case 248 /* PropertyAssignment */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 140 /* Parameter */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 250 /* ShorthandPropertyAssignment */: + case 249 /* PropertyAssignment */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5490,31 +5664,70 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 264 /* JSDocFunctionType */ && + return node.kind === 265 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 266 /* JSDocConstructorType */; + node.parameters[0].type.kind === 267 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind) { - if (node && node.jsDocComment) { - for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.kind === kind) { - return tag; - } + function getJSDocTag(node, kind, checkParentVariableStatement) { + if (!node) { + return undefined; + } + var jsDocComment = getJSDocComment(node, checkParentVariableStatement); + if (!jsDocComment) { + return undefined; + } + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === kind) { + return tag; } } } + function getJSDocComment(node, checkParentVariableStatement) { + if (node.jsDocComment) { + return node.jsDocComment; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + if (checkParentVariableStatement) { + var isInitializerOfVariableDeclarationInStatement = node.parent.kind === 215 /* VariableDeclaration */ && + node.parent.initializer === node && + node.parent.parent.parent.kind === 197 /* VariableStatement */; + var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; + if (variableStatementNode) { + return variableStatementNode.jsDocComment; + } + // Also recognize when the node is the RHS of an assignment expression + var parent_3 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_3 && parent_3.parent && + parent_3.kind === 185 /* BinaryExpression */ && + parent_3.operatorToken.kind === 56 /* EqualsToken */ && + parent_3.parent.kind === 199 /* ExpressionStatement */; + if (isSourceOfAssignmentExpressionStatement) { + return parent_3.parent.jsDocComment; + } + var isPropertyAssignmentExpression = parent_3 && parent_3.kind === 249 /* PropertyAssignment */; + if (isPropertyAssignmentExpression) { + return parent_3.jsDocComment; + } + } + return undefined; + } function getJSDocTypeTag(node) { - return getJSDocTag(node, 272 /* JSDocTypeTag */); + return getJSDocTag(node, 273 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 271 /* JSDocReturnTag */); + return getJSDocTag(node, 272 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 273 /* JSDocTemplateTag */); + return getJSDocTag(node, 274 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -5522,19 +5735,21 @@ var ts; // 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 === 270 /* JSDocParameterTag */) { - var parameterTag = t; + var jsDocComment = getJSDocComment(parameter.parent, /*checkParentVariableStatement*/ true); + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === 271 /* JSDocParameterTag */) { + var parameterTag = tag; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { - return t; + return parameterTag; } } - }); + } } } + return undefined; } ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; function hasRestParameter(s) { @@ -5543,13 +5758,13 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { if (node) { - if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 265 /* JSDocVariadicType */) { + if (node.flags & 134217728 /* JavaScriptFile */) { + if (node.type && node.type.kind === 266 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 265 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 266 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5570,7 +5785,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 165 /* ArrayBindingPattern */ || node.kind === 164 /* ObjectBindingPattern */); + return !!node && (node.kind === 166 /* ArrayBindingPattern */ || node.kind === 165 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isNodeDescendentOf(node, ancestor) { @@ -5584,7 +5799,7 @@ var ts; ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (4 /* Ambient */ | 4096 /* DeclarationFile */)) { + if (node.flags & 2 /* Ambient */ || (node.kind === 252 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -5594,34 +5809,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 177 /* ArrowFunction */: - case 166 /* BindingElement */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 145 /* Constructor */: - case 220 /* EnumDeclaration */: - case 250 /* EnumMember */: - case 233 /* ExportSpecifier */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 146 /* GetAccessor */: - case 226 /* ImportClause */: - case 224 /* ImportEqualsDeclaration */: - case 229 /* ImportSpecifier */: - case 218 /* InterfaceDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 221 /* ModuleDeclaration */: - case 227 /* NamespaceImport */: - case 139 /* Parameter */: - case 248 /* PropertyAssignment */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 147 /* SetAccessor */: - case 249 /* ShorthandPropertyAssignment */: - case 219 /* TypeAliasDeclaration */: - case 138 /* TypeParameter */: - case 214 /* VariableDeclaration */: + case 178 /* ArrowFunction */: + case 167 /* BindingElement */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 146 /* Constructor */: + case 221 /* EnumDeclaration */: + case 251 /* EnumMember */: + case 234 /* ExportSpecifier */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 147 /* GetAccessor */: + case 227 /* ImportClause */: + case 225 /* ImportEqualsDeclaration */: + case 230 /* ImportSpecifier */: + case 219 /* InterfaceDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 222 /* ModuleDeclaration */: + case 228 /* NamespaceImport */: + case 140 /* Parameter */: + case 249 /* PropertyAssignment */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 148 /* SetAccessor */: + case 250 /* ShorthandPropertyAssignment */: + case 220 /* TypeAliasDeclaration */: + case 139 /* TypeParameter */: + case 215 /* VariableDeclaration */: return true; } return false; @@ -5629,25 +5844,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 206 /* BreakStatement */: - case 205 /* ContinueStatement */: - case 213 /* DebuggerStatement */: - case 200 /* DoStatement */: - case 198 /* ExpressionStatement */: - case 197 /* EmptyStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 202 /* ForStatement */: - case 199 /* IfStatement */: - case 210 /* LabeledStatement */: - case 207 /* ReturnStatement */: - case 209 /* SwitchStatement */: - case 211 /* ThrowStatement */: - case 212 /* TryStatement */: - case 196 /* VariableStatement */: - case 201 /* WhileStatement */: - case 208 /* WithStatement */: - case 230 /* ExportAssignment */: + case 207 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 214 /* DebuggerStatement */: + case 201 /* DoStatement */: + case 199 /* ExpressionStatement */: + case 198 /* EmptyStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 203 /* ForStatement */: + case 200 /* IfStatement */: + case 211 /* LabeledStatement */: + case 208 /* ReturnStatement */: + case 210 /* SwitchStatement */: + case 212 /* ThrowStatement */: + case 213 /* TryStatement */: + case 197 /* VariableStatement */: + case 202 /* WhileStatement */: + case 209 /* WithStatement */: + case 231 /* ExportAssignment */: return true; default: return false; @@ -5656,13 +5871,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 145 /* Constructor */: - case 142 /* PropertyDeclaration */: - case 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 143 /* MethodSignature */: - case 150 /* IndexSignature */: + case 146 /* Constructor */: + case 143 /* PropertyDeclaration */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 144 /* MethodSignature */: + case 151 /* IndexSignature */: return true; default: return false; @@ -5675,7 +5890,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 229 /* ImportSpecifier */ || parent.kind === 233 /* ExportSpecifier */) { + if (parent.kind === 230 /* ImportSpecifier */ || parent.kind === 234 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5690,31 +5905,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 250 /* EnumMember */: - case 248 /* PropertyAssignment */: - case 169 /* PropertyAccessExpression */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 251 /* EnumMember */: + case 249 /* PropertyAssignment */: + case 170 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 136 /* QualifiedName */) { + while (parent.kind === 137 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 155 /* TypeQuery */; + return parent.kind === 156 /* TypeQuery */; } return false; - case 166 /* BindingElement */: - case 229 /* ImportSpecifier */: + case 167 /* BindingElement */: + case 230 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 233 /* ExportSpecifier */: + case 234 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -5730,12 +5945,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 224 /* ImportEqualsDeclaration */ || - node.kind === 226 /* ImportClause */ && !!node.name || - node.kind === 227 /* NamespaceImport */ || - node.kind === 229 /* ImportSpecifier */ || - node.kind === 233 /* ExportSpecifier */ || - node.kind === 230 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; + return node.kind === 225 /* ImportEqualsDeclaration */ || + node.kind === 227 /* ImportClause */ && !!node.name || + node.kind === 228 /* NamespaceImport */ || + node.kind === 230 /* ImportSpecifier */ || + node.kind === 234 /* ExportSpecifier */ || + node.kind === 231 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5817,7 +6032,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 135 /* LastKeyword */; + return 70 /* FirstKeyword */ <= token && token <= 136 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5844,7 +6059,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 137 /* ComputedPropertyName */ && + return name.kind === 138 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -5862,7 +6077,7 @@ var ts; if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 137 /* ComputedPropertyName */) { + if (name.kind === 138 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5894,6 +6109,7 @@ var ts; case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: + case 127 /* ReadonlyKeyword */: case 113 /* StaticKeyword */: return true; } @@ -5902,18 +6118,18 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 139 /* Parameter */; + return root.kind === 140 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 166 /* BindingElement */) { + while (node.kind === 167 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 221 /* ModuleDeclaration */ || n.kind === 251 /* SourceFile */; + return isFunctionLike(n) || n.kind === 222 /* ModuleDeclaration */ || n.kind === 252 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; /** @@ -5963,7 +6179,7 @@ var ts; } ts.cloneEntityName = cloneEntityName; function isQualifiedName(node) { - return node.kind === 136 /* QualifiedName */; + return node.kind === 137 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function nodeIsSynthesized(node) { @@ -6219,9 +6435,9 @@ var ts; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { - return compilerOptions.module ? + return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; + getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function forEachExpectedEmitFile(host, action, targetSourceFile) { @@ -6240,7 +6456,22 @@ var ts; } } function onSingleFileEmit(host, sourceFile) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, sourceFile.languageVariant === 1 /* JSX */ && options.jsx === 1 /* Preserve */ ? ".jsx" : ".js"); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + var extension = ".js"; + if (options.jsx === 1 /* Preserve */) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === 1 /* JSX */) { + // TypeScript source file preserving JSX syntax + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); var emitFileNames = { jsFilePath: jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), @@ -6293,7 +6524,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 145 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 146 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6310,10 +6541,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 146 /* GetAccessor */) { + if (accessor.kind === 147 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 147 /* SetAccessor */) { + else if (accessor.kind === 148 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6322,8 +6553,8 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 146 /* GetAccessor */ || member.kind === 147 /* SetAccessor */) - && (member.flags & 64 /* Static */) === (accessor.flags & 64 /* Static */)) { + if ((member.kind === 147 /* GetAccessor */ || member.kind === 148 /* SetAccessor */) + && (member.flags & 32 /* Static */) === (accessor.flags & 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -6333,10 +6564,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 146 /* GetAccessor */ && !getAccessor) { + if (member.kind === 147 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 147 /* SetAccessor */ && !setAccessor) { + if (member.kind === 148 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6403,7 +6634,7 @@ var ts; } if (leadingComments) { var detachedComments = []; - var lastComment; + var lastComment = void 0; for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { var comment = leadingComments_1[_i]; if (lastComment) { @@ -6444,7 +6675,7 @@ var ts; if (text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, comment.pos); var lineCount = lineMap.length; - var firstCommentLineIndent; + var firstCommentLineIndent = void 0; for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { var nextLineStart = (currentLine + 1) === lineCount ? text.length + 1 @@ -6529,16 +6760,17 @@ var ts; } function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 64 /* Static */; - case 112 /* PublicKeyword */: return 8 /* Public */; - case 111 /* ProtectedKeyword */: return 32 /* Protected */; - case 110 /* PrivateKeyword */: return 16 /* Private */; + case 113 /* StaticKeyword */: return 32 /* Static */; + case 112 /* PublicKeyword */: return 4 /* Public */; + case 111 /* ProtectedKeyword */: return 16 /* Protected */; + case 110 /* PrivateKeyword */: return 8 /* Private */; case 115 /* AbstractKeyword */: return 128 /* Abstract */; - case 82 /* ExportKeyword */: return 2 /* Export */; - case 122 /* DeclareKeyword */: return 4 /* Ambient */; - case 74 /* ConstKeyword */: return 16384 /* Const */; + case 82 /* ExportKeyword */: return 1 /* Export */; + case 122 /* DeclareKeyword */: return 2 /* Ambient */; + case 74 /* ConstKeyword */: return 2048 /* Const */; case 77 /* DefaultKeyword */: return 512 /* Default */; case 118 /* AsyncKeyword */: return 256 /* Async */; + case 127 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0; } @@ -6546,24 +6778,24 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: - case 172 /* NewExpression */: - case 171 /* CallExpression */: - case 236 /* JsxElement */: - case 237 /* JsxSelfClosingElement */: - case 173 /* TaggedTemplateExpression */: - case 167 /* ArrayLiteralExpression */: - case 175 /* ParenthesizedExpression */: - case 168 /* ObjectLiteralExpression */: - case 189 /* ClassExpression */: - case 176 /* FunctionExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 173 /* NewExpression */: + case 172 /* CallExpression */: + case 237 /* JsxElement */: + case 238 /* JsxSelfClosingElement */: + case 174 /* TaggedTemplateExpression */: + case 168 /* ArrayLiteralExpression */: + case 176 /* ParenthesizedExpression */: + case 169 /* ObjectLiteralExpression */: + case 190 /* ClassExpression */: + case 177 /* FunctionExpression */: case 69 /* Identifier */: case 10 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: case 84 /* FalseKeyword */: case 93 /* NullKeyword */: case 97 /* ThisKeyword */: @@ -6580,7 +6812,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 191 /* ExpressionWithTypeArguments */ && + return node.kind === 192 /* ExpressionWithTypeArguments */ && node.parent.token === 83 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } @@ -6603,16 +6835,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 137 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 170 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 168 /* ObjectLiteralExpression */) { + if (kind === 169 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 167 /* ArrayLiteralExpression */) { + if (kind === 168 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -6726,7 +6958,7 @@ var ts; else if (i + 2 >= length) { byte4 = 64; } - // Write to the ouput + // Write to the output result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); i += 3; } @@ -6912,9 +7144,9 @@ var ts; // . | \ // ----------------------------------------------------------------------*-------------------------------- // - // (Note the dots represent the newly inferrred start. + // (Note the dots represent the newly inferred start. // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the - // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see + // absolute positions at the asterisks, and the relative change between the dollar signs. Basically, we see // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that // means: // @@ -6937,8 +7169,8 @@ var ts; // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started // that's the same as if we started at char 80 instead of 60. // - // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter - // than pusing the first edit forward to match the second, we'll push the second edit forward to match the + // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rather + // than pushing the first edit forward to match the second, we'll push the second edit forward to match the // first. // // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange @@ -6967,9 +7199,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 138 /* TypeParameter */) { + if (d && d.kind === 139 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 218 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 219 /* InterfaceDeclaration */) { return current; } } @@ -6977,7 +7209,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 145 /* Constructor */ && ts.isClassLike(node.parent.parent); + return node.flags & 28 /* AccessibilityModifier */ && node.parent.kind === 146 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; })(ts || (ts = {})); @@ -6989,7 +7221,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 251 /* SourceFile */) { + if (kind === 252 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else { @@ -7032,26 +7264,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 249 /* ShorthandPropertyAssignment */: + case 250 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 139 /* Parameter */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 248 /* PropertyAssignment */: - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: + case 140 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 249 /* PropertyAssignment */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7060,24 +7292,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7088,302 +7320,319 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 152 /* TypeReference */: + case 153 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 156 /* TypeLiteral */: + case 157 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 157 /* ArrayType */: + case 158 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 158 /* TupleType */: + case 159 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 159 /* UnionType */: - case 160 /* IntersectionType */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 169 /* PropertyAccessExpression */: + case 170 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 170 /* ElementAccessExpression */: + case 171 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 174 /* TypeAssertionExpression */: + case 175 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 178 /* DeleteExpression */: + case 179 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 179 /* TypeOfExpression */: + case 180 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 180 /* VoidExpression */: + case 181 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 181 /* AwaitExpression */: + case 182 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 183 /* PostfixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 192 /* AsExpression */: + case 193 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 188 /* SpreadElementExpression */: + case 189 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 195 /* Block */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 215 /* VariableDeclarationList */: + case 216 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 199 /* IfStatement */: + case 200 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 200 /* DoStatement */: + case 201 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 202 /* ForStatement */: + case 203 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 203 /* ForInStatement */: + case 204 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204 /* ForOfStatement */: + case 205 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 205 /* ContinueStatement */: - case 206 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 207 /* BreakStatement */: return visitNode(cbNode, node.label); - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 208 /* WithStatement */: + case 209 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 223 /* CaseBlock */: + case 224 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 244 /* CaseClause */: + case 245 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 245 /* DefaultClause */: + case 246 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 211 /* ThrowStatement */: + case 212 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 212 /* TryStatement */: + case 213 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 140 /* Decorator */: + case 141 /* Decorator */: return visitNode(cbNode, node.expression); - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* 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 218 /* InterfaceDeclaration */: + case 219 /* 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 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 226 /* ImportClause */: + case 227 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 227 /* NamespaceImport */: + case 228 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 228 /* NamedImports */: - case 232 /* NamedExports */: + case 229 /* NamedImports */: + case 233 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 229 /* ImportSpecifier */: - case 233 /* ExportSpecifier */: + case 230 /* ImportSpecifier */: + case 234 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 193 /* TemplateSpan */: + case 194 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 246 /* HeritageClause */: + case 247 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 235 /* ExternalModuleReference */: + case 236 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 234 /* MissingDeclaration */: + case 235 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 236 /* JsxElement */: + case 237 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 237 /* JsxSelfClosingElement */: - case 238 /* JsxOpeningElement */: + case 238 /* JsxSelfClosingElement */: + case 239 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 241 /* JsxAttribute */: + case 242 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 242 /* JsxSpreadAttribute */: + case 243 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 240 /* JsxClosingElement */: + case 241 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 252 /* JSDocTypeExpression */: + case 253 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 256 /* JSDocUnionType */: + case 257 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 257 /* JSDocTupleType */: + case 258 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 255 /* JSDocArrayType */: + case 256 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 259 /* JSDocNonNullableType */: + case 260 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 258 /* JSDocNullableType */: + case 259 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 260 /* JSDocRecordType */: + case 261 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 262 /* JSDocTypeReference */: + case 263 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 263 /* JSDocOptionalType */: + case 264 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 264 /* JSDocFunctionType */: + case 265 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 265 /* JSDocVariadicType */: + case 266 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 266 /* JSDocConstructorType */: + case 267 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 267 /* JSDocThisType */: + case 268 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 261 /* JSDocRecordMember */: + case 262 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 268 /* JSDocComment */: + case 269 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 270 /* JSDocParameterTag */: + case 271 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 271 /* JSDocReturnTag */: + case 272 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 272 /* JSDocTypeTag */: + case 273 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 273 /* JSDocTemplateTag */: + case 274 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } ts.forEachChild = forEachChild; - function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { + function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); ts.parseTime += new Date().getTime() - start; return result; } ts.createSourceFile = createSourceFile; + /* @internal */ + function getScriptKindFromFileName(fileName) { + var ext = fileName.substr(fileName.lastIndexOf(".")); + switch (ext.toLowerCase()) { + case ".js": + return 1 /* JS */; + case ".jsx": + return 2 /* JSX */; + case ".ts": + return 3 /* TS */; + case ".tsx": + return 4 /* TSX */; + default: + return 3 /* TS */; + } + } + ts.getScriptKindFromFileName = getScriptKindFromFileName; // Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter // indicates what changed between the 'text' that this SourceFile has and the 'newText'. // The SourceFile will be created with the compiler attempting to reuse as many nodes from @@ -7416,7 +7665,7 @@ var ts; // 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 */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; + var disallowInAndDecoratorContext = 4194304 /* DisallowInContext */ | 16777216 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; var SourceFileConstructor; @@ -7504,19 +7753,24 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; - initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); - var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); + function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + // Using scriptKind as a condition handles both: + // - 'scriptKind' is unspecified and thus it is `undefined` + // - 'scriptKind' is set and it is `Unknown` (0) + // If the 'scriptKind' is 'undefined' or 'Unknown' then attempt + // to get the ScriptKind from the file name. + scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName); + initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function getLanguageVariant(fileName) { + function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx") ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ ? 1 /* JSX */ : 0 /* Standard */; } - function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor(); sourceText = _sourceText; @@ -7526,30 +7780,28 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = isJavaScriptFile ? 32 /* JavaScriptFile */ : 0 /* None */; + contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 134217728 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(getLanguageVariant(fileName)); + scanner.setLanguageVariant(getLanguageVariant(scriptKind)); } function clearState() { // Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. scanner.setText(""); scanner.setOnError(undefined); - // Clear any data. We don't want to accidently hold onto it for too long. + // Clear any data. We don't want to accidentally hold onto it for too long. parseDiagnostics = undefined; sourceFile = undefined; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; } - function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { - sourceFile = createSourceFile(fileName, languageVersion); - if (contextFlags & 32 /* JavaScriptFile */) { - sourceFile.parserContextFlags = 32 /* JavaScriptFile */; - } + function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { + sourceFile = createSourceFile(fileName, languageVersion, scriptKind); + sourceFile.flags = contextFlags; // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); @@ -7564,40 +7816,22 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - // If this is a javascript file, proactively see if we can get JSDoc comments for - // relevant nodes in the file. We'll use these to provide typing informaion if they're - // available. - if (ts.isSourceFileJavaScript(sourceFile)) { - addJSDocComments(); - } return sourceFile; } - function addJSDocComments() { - forEachChild(sourceFile, visit); - return; - function visit(node) { - // Add additional cases as necessary depending on how we see JSDoc comments used - // in the wild. - switch (node.kind) { - case 196 /* VariableStatement */: - case 216 /* FunctionDeclaration */: - case 139 /* Parameter */: - addJSDocComment(node); - } - forEachChild(node, visit); - } - } function addJSDocComment(node) { - var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (jsDocComment) { - node.jsDocComment = jsDocComment; + if (contextFlags & 134217728 /* JavaScriptFile */) { + var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (jsDocComment) { + node.jsDocComment = jsDocComment; + } } } } + return node; } function fixupParentReferences(sourceFile) { // normally parent references are set during binding. However, for clients that only need @@ -7621,17 +7855,18 @@ var ts; } } Parser.fixupParentReferences = fixupParentReferences; - function createSourceFile(fileName, languageVersion) { + function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(251 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(252 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 /* DeclarationFile */ : 0; - sourceFile.languageVariant = getLanguageVariant(sourceFile.fileName); + sourceFile.languageVariant = getLanguageVariant(scriptKind); + sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts"); + sourceFile.scriptKind = scriptKind; return sourceFile; } function setContextFlag(val, flag) { @@ -7643,16 +7878,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 1 /* DisallowIn */); + setContextFlag(val, 4194304 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 2 /* Yield */); + setContextFlag(val, 8388608 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 4 /* Decorator */); + setContextFlag(val, 16777216 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 8 /* Await */); + setContextFlag(val, 33554432 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -7693,40 +7928,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(1 /* DisallowIn */, func); + return doOutsideOfContext(4194304 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(1 /* DisallowIn */, func); + return doInsideOfContext(4194304 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(2 /* Yield */, func); + return doInsideOfContext(8388608 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(4 /* Decorator */, func); + return doInsideOfContext(16777216 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(8 /* Await */, func); + return doInsideOfContext(33554432 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(8 /* Await */, func); + return doOutsideOfContext(33554432 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(2 /* Yield */ | 8 /* Await */, func); + return doInsideOfContext(8388608 /* YieldContext */ | 33554432 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(2 /* Yield */); + return inContext(8388608 /* YieldContext */); } function inDisallowInContext() { - return inContext(1 /* DisallowIn */); + return inContext(4194304 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(4 /* Decorator */); + return inContext(16777216 /* DecoratorContext */); } function inAwaitContext() { - return inContext(8 /* Await */); + return inContext(33554432 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -7900,14 +8135,14 @@ var ts; function finishNode(node, end) { node.end = end === undefined ? scanner.getStartPos() : end; if (contextFlags) { - node.parserContextFlags = contextFlags; + node.flags |= contextFlags; } // Keep track on the node if we encountered an error while parsing it. If we did, then // we cannot reuse the node incrementally. Once we've marked this node, clear out the // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16 /* ThisNodeHasError */; + node.flags |= 67108864 /* ThisNodeHasError */; } return node; } @@ -7976,7 +8211,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(137 /* ComputedPropertyName */); + var node = createNode(138 /* 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 @@ -8049,7 +8284,7 @@ var ts; case 2 /* SwitchClauses */: return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 4 /* TypeMembers */: - return isStartOfTypeMember(); + return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant @@ -8289,20 +8524,20 @@ var ts; // We can only reuse a node if it was parsed under the same strict mode that we're // currently in. i.e. if we originally parsed a node in non-strict mode, but then // the user added 'using strict' at the top of the file, then we can't use that node - // again as the presense of strict mode may cause us to parse the tokens in the file - // differetly. + // again as the presence of strict mode may cause us to parse the tokens in the file + // differently. // // Note: we *can* reuse tokens when the strict mode changes. That's because tokens // are unaffected by strict mode. It's just the parser will decide what to do with it // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 31 /* ParserGeneratedFlags */; + var nodeContextFlags = node.flags & 62914560 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } // Ok, we have a node that looks like it could be reused. Now verify that it is valid - // in the currest list parsing context that we're currently at. + // in the current list parsing context that we're currently at. if (!canReuseNode(node, parsingContext)) { return undefined; } @@ -8377,14 +8612,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 145 /* Constructor */: - case 150 /* IndexSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 142 /* PropertyDeclaration */: - case 194 /* SemicolonClassElement */: + case 146 /* Constructor */: + case 151 /* IndexSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 143 /* PropertyDeclaration */: + case 195 /* SemicolonClassElement */: return true; - case 144 /* MethodDeclaration */: + case 145 /* 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. @@ -8399,8 +8634,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 244 /* CaseClause */: - case 245 /* DefaultClause */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: return true; } } @@ -8409,58 +8644,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 216 /* FunctionDeclaration */: - case 196 /* VariableStatement */: - case 195 /* Block */: - case 199 /* IfStatement */: - case 198 /* ExpressionStatement */: - case 211 /* ThrowStatement */: - case 207 /* ReturnStatement */: - case 209 /* SwitchStatement */: - case 206 /* BreakStatement */: - case 205 /* ContinueStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 202 /* ForStatement */: - case 201 /* WhileStatement */: - case 208 /* WithStatement */: - case 197 /* EmptyStatement */: - case 212 /* TryStatement */: - case 210 /* LabeledStatement */: - case 200 /* DoStatement */: - case 213 /* DebuggerStatement */: - case 225 /* ImportDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 231 /* ExportDeclaration */: - case 230 /* ExportAssignment */: - case 221 /* ModuleDeclaration */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 219 /* TypeAliasDeclaration */: + case 217 /* FunctionDeclaration */: + case 197 /* VariableStatement */: + case 196 /* Block */: + case 200 /* IfStatement */: + case 199 /* ExpressionStatement */: + case 212 /* ThrowStatement */: + case 208 /* ReturnStatement */: + case 210 /* SwitchStatement */: + case 207 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 203 /* ForStatement */: + case 202 /* WhileStatement */: + case 209 /* WithStatement */: + case 198 /* EmptyStatement */: + case 213 /* TryStatement */: + case 211 /* LabeledStatement */: + case 201 /* DoStatement */: + case 214 /* DebuggerStatement */: + case 226 /* ImportDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 232 /* ExportDeclaration */: + case 231 /* ExportAssignment */: + case 222 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 220 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 250 /* EnumMember */; + return node.kind === 251 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 149 /* ConstructSignature */: - case 143 /* MethodSignature */: - case 150 /* IndexSignature */: - case 141 /* PropertySignature */: - case 148 /* CallSignature */: + case 150 /* ConstructSignature */: + case 144 /* MethodSignature */: + case 151 /* IndexSignature */: + case 142 /* PropertySignature */: + case 149 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 214 /* VariableDeclaration */) { + if (node.kind !== 215 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8481,7 +8716,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 139 /* Parameter */) { + if (node.kind !== 140 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8529,7 +8764,7 @@ var ts; } ; // Parses a comma-delimited list of elements - function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimeter) { + function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; @@ -8554,7 +8789,7 @@ var ts; // 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 === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -8598,7 +8833,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21 /* DotToken */)) { - var node = createNode(136 /* QualifiedName */, entity.pos); + var node = createNode(137 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8637,7 +8872,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(186 /* TemplateExpression */); + var template = createNode(187 /* TemplateExpression */); template.head = parseTemplateLiteralFragment(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8650,7 +8885,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(193 /* TemplateSpan */); + var span = createNode(194 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 16 /* CloseBraceToken */) { @@ -8664,7 +8899,7 @@ var ts; return finishNode(span); } function parseStringLiteralTypeNode() { - return parseLiteralLikeNode(163 /* StringLiteralType */, /*internName*/ true); + return parseLiteralLikeNode(164 /* StringLiteralType */, /*internName*/ true); } function parseLiteralNode(internName) { return parseLiteralLikeNode(token, internName); @@ -8694,40 +8929,40 @@ var ts; if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 32768 /* OctalLiteral */; + node.isOctalLiteral = true; } return node; } // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(152 /* TypeReference */, typeName.pos); + var node = createNode(153 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } - function parseTypePredicate(lhs) { + function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(151 /* TypePredicate */, lhs.pos); + var node = createNode(152 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(162 /* ThisType */); + var node = createNode(163 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(155 /* TypeQuery */); + var node = createNode(156 /* TypeQuery */); parseExpected(101 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(138 /* TypeParameter */); + var node = createNode(139 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(83 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -8771,7 +9006,7 @@ var ts; } } function parseParameter() { - var node = createNode(139 /* Parameter */); + var node = createNode(140 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); @@ -8800,7 +9035,7 @@ var ts; // contexts. In addition, parameter initializers are semantically disallowed in // overload signatures. So parameter initializers are transitively disallowed in // ambient contexts. - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseBindingElementInitializer(inParameter) { return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); @@ -8865,7 +9100,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 149 /* ConstructSignature */) { + if (kind === 150 /* ConstructSignature */) { parseExpected(92 /* NewKeyword */); } fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -8929,7 +9164,7 @@ var ts; return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(150 /* IndexSignature */, fullStart); + var node = createNode(151 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); @@ -8937,22 +9172,23 @@ var ts; parseTypeMemberSemicolon(); return finishNode(node); } - function parsePropertyOrMethodSignature() { - var fullStart = scanner.getStartPos(); + function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); var questionToken = parseOptionalToken(53 /* QuestionToken */); if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(143 /* MethodSignature */, fullStart); + var method = createNode(144 /* MethodSignature */, fullStart); + setModifiers(method, modifiers); method.name = name; method.questionToken = questionToken; - // Method signatues don't exist in expression contexts. So they have neither + // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(141 /* PropertySignature */, fullStart); + var property = createNode(142 /* PropertySignature */, fullStart); + setModifiers(property, modifiers); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8966,86 +9202,57 @@ var ts; return finishNode(property); } } - function isStartOfTypeMember() { - switch (token) { - case 17 /* OpenParenToken */: - case 25 /* LessThanToken */: - case 19 /* OpenBracketToken */: - return true; - default: - if (ts.isModifierKind(token)) { - var result = lookAhead(isStartOfIndexSignatureDeclaration); - if (result) { - return result; - } - } - return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); + function isTypeMemberStart() { + var idToken; + // Return true if we have the start of a signature member + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + return true; } - } - function isStartOfIndexSignatureDeclaration() { + // Eat up all modifiers, but hold on to the last one in case it is actually an identifier while (ts.isModifierKind(token)) { + idToken = token; nextToken(); } - return isIndexSignature(); - } - function isTypeMemberWithLiteralPropertyName() { - nextToken(); - return token === 17 /* OpenParenToken */ || - token === 25 /* LessThanToken */ || - token === 53 /* QuestionToken */ || - token === 54 /* ColonToken */ || - canParseSemicolon(); + // Index signatures and computed property names are type members + if (token === 19 /* OpenBracketToken */) { + return true; + } + // Try to get the first property-like token following all modifiers + if (isLiteralPropertyName()) { + idToken = token; + nextToken(); + } + // If we were able to get any potential identifier, check that it is + // the start of a member declaration + if (idToken) { + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 53 /* QuestionToken */ || + token === 54 /* ColonToken */ || + canParseSemicolon(); + } + return false; } function parseTypeMember() { - switch (token) { - case 17 /* OpenParenToken */: - case 25 /* LessThanToken */: - return parseSignatureMember(148 /* CallSignature */); - case 19 /* OpenBracketToken */: - // Indexer or computed property - return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) - : parsePropertyOrMethodSignature(); - case 92 /* NewKeyword */: - if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(149 /* ConstructSignature */); - } - // fall through. - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - return parsePropertyOrMethodSignature(); - default: - // Index declaration as allowed as a type member. But as per the grammar, - // they also allow modifiers. So we have to check for an index declaration - // that might be following modifiers. This ensures that things work properly - // when incrementally parsing as the parser will produce the Index declaration - // if it has the same text regardless of whether it is inside a class or an - // object type. - if (ts.isModifierKind(token)) { - var result = tryParse(parseIndexSignatureWithModifiers); - if (result) { - return result; - } - } - if (ts.tokenIsIdentifierOrKeyword(token)) { - return parsePropertyOrMethodSignature(); - } + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + return parseSignatureMember(149 /* CallSignature */); } - } - function parseIndexSignatureWithModifiers() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); + if (token === 92 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(150 /* ConstructSignature */); + } + var fullStart = getNodePos(); var modifiers = parseModifiers(); - return isIndexSignature() - ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) - : undefined; + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, /*decorators*/ undefined, modifiers); + } + return parsePropertyOrMethodSignature(fullStart, modifiers); } function isStartOfConstructSignature() { nextToken(); return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(156 /* TypeLiteral */); + var node = createNode(157 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -9061,12 +9268,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(158 /* TupleType */); + var node = createNode(159 /* TupleType */); node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(161 /* ParenthesizedType */); + var node = createNode(162 /* ParenthesizedType */); parseExpected(17 /* OpenParenToken */); node.type = parseType(); parseExpected(18 /* CloseParenToken */); @@ -9074,7 +9281,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 154 /* ConstructorType */) { + if (kind === 155 /* ConstructorType */) { parseExpected(92 /* NewKeyword */); } fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -9087,10 +9294,10 @@ var ts; function parseNonArrayType() { switch (token) { case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -9101,7 +9308,7 @@ var ts; case 97 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); if (token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { - return parseTypePredicate(thisKeyword); + return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; @@ -9122,10 +9329,10 @@ var ts; function isStartOfType() { switch (token) { case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: case 103 /* VoidKeyword */: case 97 /* ThisKeyword */: case 101 /* TypeOfKeyword */: @@ -9151,7 +9358,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { parseExpected(20 /* CloseBracketToken */); - var node = createNode(157 /* ArrayType */, type.pos); + var node = createNode(158 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9173,10 +9380,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(160 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + return parseUnionOrIntersectionType(161 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(159 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + return parseUnionOrIntersectionType(160 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); } function isStartOfFunctionType() { if (token === 25 /* LessThanToken */) { @@ -9184,6 +9391,23 @@ var ts; } return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } + function skipParameterStart() { + if (ts.isModifierKind(token)) { + // Skip modifiers + parseModifiers(); + } + if (isIdentifier()) { + nextToken(); + return true; + } + if (token === 19 /* OpenBracketToken */ || token === 15 /* OpenBraceToken */) { + // Return true if we can parse an array or object binding pattern with no errors + var previousErrorCount = parseDiagnostics.length; + parseIdentifierOrPattern(); + return previousErrorCount === parseDiagnostics.length; + } + return false; + } function isUnambiguouslyStartOfFunctionType() { nextToken(); if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { @@ -9191,22 +9415,21 @@ var ts; // ( ... return true; } - if (isIdentifier() || ts.isModifierKind(token)) { - nextToken(); + if (skipParameterStart()) { + // We successfully skipped modifiers (if any) and an identifier or binding pattern, + // now see if we have something that indicates a parameter declaration if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || - token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || - isIdentifier() || ts.isModifierKind(token)) { - // ( id : - // ( id , - // ( id ? - // ( id = - // ( modifier id + token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */) { + // ( xxx : + // ( xxx , + // ( xxx ? + // ( xxx = return true; } if (token === 18 /* CloseParenToken */) { nextToken(); if (token === 34 /* EqualsGreaterThanToken */) { - // ( id ) => + // ( xxx ) => return true; } } @@ -9217,7 +9440,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(151 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(152 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -9236,14 +9459,14 @@ var ts; function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(10 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(41943040 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(153 /* FunctionType */); + return parseFunctionOrConstructorType(154 /* FunctionType */); } if (token === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(154 /* ConstructorType */); + return parseFunctionOrConstructorType(155 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -9408,7 +9631,7 @@ var ts; } function isYieldExpression() { if (token === 114 /* YieldKeyword */) { - // If we have a 'yield' keyword, and htis is a context where yield expressions are + // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { return true; @@ -9426,7 +9649,7 @@ var ts; // // for now we just check if the next token is an identifier. More heuristics // can be added here later as necessary. We just need to make sure that we - // don't accidently consume something legal. + // don't accidentally consume something legal. return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; @@ -9436,7 +9659,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(187 /* YieldExpression */); + var node = createNode(188 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -9450,14 +9673,14 @@ var ts; } else { // if the next token is not on the same line as yield. or we don't have an '*' or - // the start of an expressin, then this is just a simple "yield" expression. + // the start of an expression, then this is just a simple "yield" expression. return finishNode(node); } } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(177 /* ArrowFunction */, identifier.pos); - var parameter = createNode(139 /* Parameter */, identifier.pos); + var node = createNode(178 /* ArrowFunction */, identifier.pos); + var parameter = createNode(140 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -9609,7 +9832,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(177 /* ArrowFunction */); + var node = createNode(178 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 256 /* Async */); // Arrow functions are never generators. @@ -9675,7 +9898,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(185 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(186 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -9688,7 +9911,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 135 /* OfKeyword */; + return t === 90 /* InKeyword */ || t === 136 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9699,7 +9922,7 @@ var ts; // Check the precedence to see if we should "take" this operator // - For left associative operator (all operator but **), consume the operator, // recursively call the function below, and parse binaryExpression as a rightOperand - // of the caller if the new precendence of the operator is greater then or equal to the current precendence. + // of the caller if the new precedence of the operator is greater then or equal to the current precedence. // For example: // a - b - c; // ^token; leftOperand = b. Return b to the caller as a rightOperand @@ -9708,8 +9931,8 @@ var ts; // a - b * c; // ^token; leftOperand = b. Return b * c to the caller as a rightOperand // - For right associative operator (**), consume the operator, recursively call the function - // and parse binaryExpression as a rightOperand of the caller if the new precendence of - // the operator is strictly grater than the current precendence + // and parse binaryExpression as a rightOperand of the caller if the new precedence of + // the operator is strictly grater than the current precedence // For example: // a ** b ** c; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand @@ -9796,39 +10019,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(184 /* BinaryExpression */, left.pos); + var node = createNode(185 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(192 /* AsExpression */, left.pos); + var node = createNode(193 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(182 /* PrefixUnaryExpression */); + var node = createNode(183 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(178 /* DeleteExpression */); + var node = createNode(179 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(179 /* TypeOfExpression */); + var node = createNode(180 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(180 /* VoidExpression */); + var node = createNode(181 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -9844,7 +10067,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(181 /* AwaitExpression */); + var node = createNode(182 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -9870,7 +10093,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token === 38 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 174 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 175 /* TypeAssertionExpression */) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -9926,7 +10149,7 @@ var ts; */ function isIncrementExpression() { // This function is called inside parseUnaryExpression to decide - // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly + // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: @@ -9960,7 +10183,7 @@ var ts; */ function parseIncrementExpression() { if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { - var node = createNode(182 /* PrefixUnaryExpression */); + var node = createNode(183 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -9973,7 +10196,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(183 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(184 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -10077,7 +10300,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(169 /* PropertyAccessExpression */, expression.pos); + var node = createNode(170 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10096,8 +10319,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 238 /* JsxOpeningElement */) { - var node = createNode(236 /* JsxElement */, opening.pos); + if (opening.kind === 239 /* JsxOpeningElement */) { + var node = createNode(237 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -10107,7 +10330,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 237 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 238 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -10122,7 +10345,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(184 /* BinaryExpression */, result.pos); + var badNode = createNode(185 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -10134,13 +10357,13 @@ var ts; return result; } function parseJsxText() { - var node = createNode(239 /* JsxText */, scanner.getStartPos()); + var node = createNode(240 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 239 /* JsxText */: + case 240 /* JsxText */: return parseJsxText(); case 15 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); @@ -10182,7 +10405,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(238 /* JsxOpeningElement */, fullStart); + node = createNode(239 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -10194,7 +10417,7 @@ var ts; parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(237 /* JsxSelfClosingElement */, fullStart); + node = createNode(238 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10205,7 +10428,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(136 /* QualifiedName */, elementName.pos); + var node = createNode(137 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -10213,7 +10436,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(243 /* JsxExpression */); + var node = createNode(244 /* JsxExpression */); parseExpected(15 /* OpenBraceToken */); if (token !== 16 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); @@ -10232,7 +10455,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(241 /* JsxAttribute */); + var node = createNode(242 /* JsxAttribute */); node.name = parseIdentifierName(); if (parseOptional(56 /* EqualsToken */)) { switch (token) { @@ -10247,7 +10470,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(242 /* JsxSpreadAttribute */); + var node = createNode(243 /* JsxSpreadAttribute */); parseExpected(15 /* OpenBraceToken */); parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); @@ -10255,7 +10478,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(240 /* JsxClosingElement */); + var node = createNode(241 /* JsxClosingElement */); parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -10268,7 +10491,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(174 /* TypeAssertionExpression */); + var node = createNode(175 /* TypeAssertionExpression */); parseExpected(25 /* LessThanToken */); node.type = parseType(); parseExpected(27 /* GreaterThanToken */); @@ -10279,7 +10502,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(169 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(170 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10288,7 +10511,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(170 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(171 /* 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. @@ -10304,7 +10527,7 @@ var ts; continue; } if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(173 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(174 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -10327,7 +10550,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(171 /* CallExpression */, expression.pos); + var callExpr = createNode(172 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -10335,7 +10558,7 @@ var ts; continue; } else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(171 /* CallExpression */, expression.pos); + var callExpr = createNode(172 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10359,7 +10582,7 @@ var ts; // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } - // If we have a '<', then only parse this as a arugment list if the type arguments + // If we have a '<', then only parse this as a argument list if the type arguments // are complete and we have an open paren. if we don't, rewind and return nothing. return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments @@ -10445,41 +10668,42 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(175 /* ParenthesizedExpression */); + var node = createNode(176 /* ParenthesizedExpression */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(188 /* SpreadElementExpression */); + var node = createNode(189 /* SpreadElementExpression */); parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(190 /* OmittedExpression */) : + token === 24 /* CommaToken */ ? createNode(191 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(167 /* ArrayLiteralExpression */); + var node = createNode(168 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); - if (scanner.hasPrecedingLineBreak()) - node.flags |= 1024 /* MultiLine */; + if (scanner.hasPrecedingLineBreak()) { + node.multiLine = true; + } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(146 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(147 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(129 /* SetKeyword */)) { - return parseAccessorDeclaration(147 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(130 /* SetKeyword */)) { + return parseAccessorDeclaration(148 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10506,7 +10730,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(249 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(250 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(56 /* EqualsToken */); @@ -10514,25 +10738,25 @@ var ts; shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } - return finishNode(shorthandDeclaration); + return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(248 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(249 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(54 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); + return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(168 /* ObjectLiteralExpression */); + var node = createNode(169 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 1024 /* MultiLine */; + node.multiLine = true; } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } @@ -10546,7 +10770,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(176 /* FunctionExpression */); + var node = createNode(177 /* FunctionExpression */); setModifiers(node, parseModifiers()); parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); @@ -10562,13 +10786,13 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(172 /* NewExpression */); + var node = createNode(173 /* NewExpression */); parseExpected(92 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -10579,7 +10803,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(195 /* Block */); + var node = createNode(196 /* Block */); if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -10609,12 +10833,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(197 /* EmptyStatement */); + var node = createNode(198 /* EmptyStatement */); parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(199 /* IfStatement */); + var node = createNode(200 /* IfStatement */); parseExpected(88 /* IfKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10624,7 +10848,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(200 /* DoStatement */); + var node = createNode(201 /* DoStatement */); parseExpected(79 /* DoKeyword */); node.statement = parseStatement(); parseExpected(104 /* WhileKeyword */); @@ -10639,7 +10863,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(201 /* WhileStatement */); + var node = createNode(202 /* WhileStatement */); parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10662,21 +10886,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(203 /* ForInStatement */, pos); + var forInStatement = createNode(204 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(135 /* OfKeyword */)) { - var forOfStatement = createNode(204 /* ForOfStatement */, pos); + else if (parseOptional(136 /* OfKeyword */)) { + var forOfStatement = createNode(205 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(202 /* ForStatement */, pos); + var forStatement = createNode(203 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(23 /* SemicolonToken */); if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { @@ -10694,7 +10918,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 206 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + parseExpected(kind === 207 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10702,7 +10926,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(207 /* ReturnStatement */); + var node = createNode(208 /* ReturnStatement */); parseExpected(94 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -10711,7 +10935,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(208 /* WithStatement */); + var node = createNode(209 /* WithStatement */); parseExpected(105 /* WithKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10720,7 +10944,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(244 /* CaseClause */); + var node = createNode(245 /* CaseClause */); parseExpected(71 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(54 /* ColonToken */); @@ -10728,7 +10952,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(245 /* DefaultClause */); + var node = createNode(246 /* DefaultClause */); parseExpected(77 /* DefaultKeyword */); parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -10738,12 +10962,12 @@ var ts; return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(209 /* SwitchStatement */); + var node = createNode(210 /* SwitchStatement */); parseExpected(96 /* SwitchKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(223 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(224 /* CaseBlock */, scanner.getStartPos()); parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(16 /* CloseBraceToken */); @@ -10758,7 +10982,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(211 /* ThrowStatement */); + var node = createNode(212 /* ThrowStatement */); parseExpected(98 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -10766,7 +10990,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(212 /* TryStatement */); + var node = createNode(213 /* TryStatement */); parseExpected(100 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -10779,7 +11003,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(247 /* CatchClause */); + var result = createNode(248 /* CatchClause */); parseExpected(72 /* CatchKeyword */); if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -10789,7 +11013,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(213 /* DebuggerStatement */); + var node = createNode(214 /* DebuggerStatement */); parseExpected(76 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -10801,16 +11025,16 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(210 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(211 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); + return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(198 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(199 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); - return finishNode(expressionStatement); + return addJSDocComment(finishNode(expressionStatement)); } } function nextTokenIsIdentifierOrKeywordOnSameLine() { @@ -10857,7 +11081,7 @@ var ts; // // could be legal, it would add complexity for very little gain. case 107 /* InterfaceKeyword */: - case 132 /* TypeKeyword */: + case 133 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: @@ -10868,13 +11092,14 @@ var ts; case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: case 112 /* PublicKeyword */: + case 127 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 134 /* GlobalKeyword */: + case 135 /* GlobalKeyword */: return nextToken() === 15 /* OpenBraceToken */; case 89 /* ImportKeyword */: nextToken(); @@ -10934,14 +11159,15 @@ var ts; case 107 /* InterfaceKeyword */: case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: - case 132 /* TypeKeyword */: - case 134 /* GlobalKeyword */: + case 133 /* TypeKeyword */: + case 135 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: case 113 /* StaticKeyword */: + case 127 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10984,9 +11210,9 @@ var ts; case 86 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(205 /* ContinueStatement */); + return parseBreakOrContinueStatement(206 /* ContinueStatement */); case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(206 /* BreakStatement */); + return parseBreakOrContinueStatement(207 /* BreakStatement */); case 94 /* ReturnKeyword */: return parseReturnStatement(); case 105 /* WithKeyword */: @@ -11006,7 +11232,7 @@ var ts; return parseDeclaration(); case 118 /* AsyncKeyword */: case 107 /* InterfaceKeyword */: - case 132 /* TypeKeyword */: + case 133 /* TypeKeyword */: case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: case 122 /* DeclareKeyword */: @@ -11019,7 +11245,8 @@ var ts; case 112 /* PublicKeyword */: case 115 /* AbstractKeyword */: case 113 /* StaticKeyword */: - case 134 /* GlobalKeyword */: + case 127 /* ReadonlyKeyword */: + case 135 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -11042,11 +11269,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 107 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 132 /* TypeKeyword */: + case 133 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 81 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 134 /* GlobalKeyword */: + case 135 /* GlobalKeyword */: case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -11061,7 +11288,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(234 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(235 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -11083,16 +11310,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 24 /* CommaToken */) { - return createNode(190 /* OmittedExpression */); + return createNode(191 /* OmittedExpression */); } - var node = createNode(166 /* BindingElement */); + var node = createNode(167 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(166 /* BindingElement */); + var node = createNode(167 /* BindingElement */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 54 /* ColonToken */) { @@ -11107,14 +11334,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(164 /* ObjectBindingPattern */); + var node = createNode(165 /* ObjectBindingPattern */); parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(165 /* ArrayBindingPattern */); + var node = createNode(166 /* ArrayBindingPattern */); parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(20 /* CloseBracketToken */); @@ -11133,7 +11360,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(214 /* VariableDeclaration */); + var node = createNode(215 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -11142,15 +11369,15 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(215 /* VariableDeclarationList */); + var node = createNode(216 /* VariableDeclarationList */); switch (token) { case 102 /* VarKeyword */: break; case 108 /* LetKeyword */: - node.flags |= 8192 /* Let */; + node.flags |= 1024 /* Let */; break; case 74 /* ConstKeyword */: - node.flags |= 16384 /* Const */; + node.flags |= 2048 /* Const */; break; default: ts.Debug.fail(); @@ -11165,7 +11392,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 === 135 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 136 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -11180,15 +11407,15 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(196 /* VariableStatement */, fullStart); + var node = createNode(197 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* FunctionDeclaration */, fullStart); + var node = createNode(217 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(87 /* FunctionKeyword */); @@ -11198,19 +11425,19 @@ var ts; var isAsync = !!(node.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(145 /* Constructor */, pos); + var node = createNode(146 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(121 /* ConstructorKeyword */); fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(144 /* MethodDeclaration */, fullStart); + var method = createNode(145 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -11220,10 +11447,10 @@ var ts; var isAsync = !!(method.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); + return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(142 /* PropertyDeclaration */, fullStart); + var property = createNode(143 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11234,13 +11461,13 @@ var ts; // off. The grammar would look something like this: // // MemberVariableDeclaration[Yield]: - // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In]; - // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; + // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initializer_opt[In]; + // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initializer_opt[In, ?Yield]; // // The checker may still error in the static case to explicitly disallow the yield expression. - property.initializer = modifiers && modifiers.flags & 64 /* Static */ + property.initializer = modifiers && modifiers.flags & 32 /* Static */ ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); + : doOutsideOfContext(8388608 /* YieldContext */ | 4194304 /* DisallowInContext */, parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } @@ -11275,6 +11502,7 @@ var ts; case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: case 113 /* StaticKeyword */: + case 127 /* ReadonlyKeyword */: return true; default: return false; @@ -11315,7 +11543,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 129 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 130 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -11349,7 +11577,7 @@ var ts; decorators = []; decorators.pos = decoratorStart; } - var decorator = createNode(140 /* Decorator */, decoratorStart); + var decorator = createNode(141 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11414,7 +11642,7 @@ var ts; } function parseClassElement() { if (token === 23 /* SemicolonToken */) { - var result = createNode(194 /* SemicolonClassElement */); + var result = createNode(195 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11452,10 +11680,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 189 /* ClassExpression */); + /*modifiers*/ undefined, 190 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 217 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 218 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -11499,7 +11727,7 @@ var ts; } function parseHeritageClause() { if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { - var node = createNode(246 /* HeritageClause */); + var node = createNode(247 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11508,7 +11736,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(191 /* ExpressionWithTypeArguments */); + var node = createNode(192 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -11522,7 +11750,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218 /* InterfaceDeclaration */, fullStart); + var node = createNode(219 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(107 /* InterfaceKeyword */); @@ -11533,10 +11761,10 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(219 /* TypeAliasDeclaration */, fullStart); + var node = createNode(220 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(132 /* TypeKeyword */); + parseExpected(133 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(56 /* EqualsToken */); @@ -11549,13 +11777,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(250 /* EnumMember */, scanner.getStartPos()); + var node = createNode(251 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220 /* EnumDeclaration */, fullStart); + var node = createNode(221 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(81 /* EnumKeyword */); @@ -11570,7 +11798,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(222 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(223 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -11581,27 +11809,27 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(221 /* ModuleDeclaration */, fullStart); + var node = createNode(222 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 65536 /* Namespace */; + var namespaceFlag = flags & 4096 /* Namespace */; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 2 /* Export */ | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221 /* ModuleDeclaration */, fullStart); + var node = createNode(222 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (token === 134 /* GlobalKeyword */) { + if (token === 135 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 2097152 /* GlobalAugmentation */; + node.flags |= 131072 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(/*internName*/ true); @@ -11611,12 +11839,12 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (token === 134 /* GlobalKeyword */) { + if (token === 135 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(126 /* NamespaceKeyword */)) { - flags |= 65536 /* Namespace */; + flags |= 4096 /* Namespace */; } else { parseExpected(125 /* ModuleKeyword */); @@ -11627,7 +11855,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 127 /* RequireKeyword */ && + return token === 128 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -11642,11 +11870,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 134 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(224 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(225 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -11657,7 +11885,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(225 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(226 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -11667,7 +11895,7 @@ var ts; token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(133 /* FromKeyword */); + parseExpected(134 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11680,7 +11908,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(226 /* ImportClause */, fullStart); + var importClause = createNode(227 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11690,7 +11918,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(228 /* NamedImports */); + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(229 /* NamedImports */); } return finishNode(importClause); } @@ -11700,8 +11928,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(235 /* ExternalModuleReference */); - parseExpected(127 /* RequireKeyword */); + var node = createNode(236 /* ExternalModuleReference */); + parseExpected(128 /* RequireKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(18 /* CloseParenToken */); @@ -11723,7 +11951,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(227 /* NamespaceImport */); + var namespaceImport = createNode(228 /* NamespaceImport */); parseExpected(37 /* AsteriskToken */); parseExpected(116 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -11738,21 +11966,21 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 228 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 229 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(233 /* ExportSpecifier */); + return parseImportOrExportSpecifier(234 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(229 /* ImportSpecifier */); + return parseImportOrExportSpecifier(230 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); // ImportSpecifier: // BindingIdentifier // IdentifierName as BindingIdentifier - // ExportSpecififer: + // ExportSpecifier: // IdentifierName // IdentifierName as IdentifierName var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); @@ -11770,27 +11998,27 @@ var ts; else { node.name = identifierName; } - if (kind === 229 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 230 /* 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(231 /* ExportDeclaration */, fullStart); + var node = createNode(232 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(133 /* FromKeyword */); + parseExpected(134 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(232 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(233 /* 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 === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(133 /* FromKeyword */); + if (token === 134 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(134 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11798,7 +12026,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(230 /* ExportAssignment */, fullStart); + var node = createNode(231 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(56 /* EqualsToken */)) { @@ -11872,11 +12100,11 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 2 /* Export */ - || node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */ - || node.kind === 225 /* ImportDeclaration */ - || node.kind === 230 /* ExportAssignment */ - || node.kind === 231 /* ExportDeclaration */ + return node.flags & 1 /* Export */ + || node.kind === 225 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 236 /* ExternalModuleReference */ + || node.kind === 226 /* ImportDeclaration */ + || node.kind === 231 /* ExportAssignment */ + || node.kind === 232 /* ExportDeclaration */ ? node : undefined; }); @@ -11937,21 +12165,19 @@ var ts; } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); - var jsDocTypeExpression = parseJSDocTypeExpression(start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + scanner.setText(content, start, length); + token = scanner.scan(); + var jsDocTypeExpression = parseJSDocTypeExpression(); var diagnostics = parseDiagnostics; clearState(); return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - // Parses out a JSDoc type expression. The starting position should be right at the open - // curly in the type expression. Returns 'undefined' if it encounters any errors while parsing. + // Parses out a JSDoc type expression. /* @internal */ - function parseJSDocTypeExpression(start, length) { - scanner.setText(sourceText, start, length); - // Prime the first token for us to start processing. - token = nextToken(); - var result = createNode(252 /* JSDocTypeExpression */); + function parseJSDocTypeExpression() { + var result = createNode(253 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(16 /* CloseBraceToken */); @@ -11962,12 +12188,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 47 /* BarToken */) { - var unionType = createNode(256 /* JSDocUnionType */, type.pos); + var unionType = createNode(257 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 56 /* EqualsToken */) { - var optionalType = createNode(263 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(264 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11978,20 +12204,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19 /* OpenBracketToken */) { - var arrayType = createNode(255 /* JSDocArrayType */, type.pos); + var arrayType = createNode(256 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token === 53 /* QuestionToken */) { - var nullableType = createNode(258 /* JSDocNullableType */, type.pos); + var nullableType = createNode(259 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 49 /* ExclamationToken */) { - var nonNullableType = createNode(259 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(260 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -12025,10 +12251,10 @@ var ts; case 97 /* ThisKeyword */: return parseJSDocThisType(); case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: case 103 /* VoidKeyword */: return parseTokenNode(); } @@ -12036,27 +12262,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(267 /* JSDocThisType */); + var result = createNode(268 /* JSDocThisType */); nextToken(); parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(266 /* JSDocConstructorType */); + var result = createNode(267 /* JSDocConstructorType */); nextToken(); parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(265 /* JSDocVariadicType */); + var result = createNode(266 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(264 /* JSDocFunctionType */); + var result = createNode(265 /* JSDocFunctionType */); nextToken(); parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -12069,20 +12295,28 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(139 /* Parameter */); + var parameter = createNode(140 /* Parameter */); parameter.type = parseJSDocType(); + if (parseOptional(56 /* EqualsToken */)) { + parameter.questionToken = createNode(56 /* EqualsToken */); + } return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(262 /* JSDocTypeReference */); + var result = createNode(263 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - while (parseOptional(21 /* DotToken */)) { - if (token === 25 /* LessThanToken */) { - result.typeArguments = parseTypeArguments(); - break; - } - else { - result.name = parseQualifiedName(result.name); + if (token === 25 /* LessThanToken */) { + result.typeArguments = parseTypeArguments(); + } + else { + while (parseOptional(21 /* DotToken */)) { + if (token === 25 /* LessThanToken */) { + result.typeArguments = parseTypeArguments(); + break; + } + else { + result.name = parseQualifiedName(result.name); + } } } return finishNode(result); @@ -12104,13 +12338,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(136 /* QualifiedName */, left.pos); + var result = createNode(137 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(260 /* JSDocRecordType */); + var result = createNode(261 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -12118,7 +12352,7 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(261 /* JSDocRecordMember */); + var result = createNode(262 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); if (token === 54 /* ColonToken */) { nextToken(); @@ -12127,13 +12361,13 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(259 /* JSDocNonNullableType */); + var result = createNode(260 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(257 /* JSDocTupleType */); + var result = createNode(258 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -12147,7 +12381,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(256 /* JSDocUnionType */); + var result = createNode(257 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18 /* CloseParenToken */); @@ -12165,7 +12399,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(253 /* JSDocAllType */); + var result = createNode(254 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -12188,29 +12422,35 @@ var ts; token === 27 /* GreaterThanToken */ || token === 56 /* EqualsToken */ || token === 47 /* BarToken */) { - var result = createNode(254 /* JSDocUnknownType */, pos); + var result = createNode(255 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(258 /* JSDocNullableType */, pos); + var result = createNode(259 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); - var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDocComment = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; } JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; function parseJSDocComment(parent, start, length) { + var saveToken = token; + var saveParseDiagnosticsLength = parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; var comment = parseJSDocCommentWorker(start, length); if (comment) { - fixupParentReferences(comment); comment.parent = parent; } + token = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; @@ -12223,77 +12463,75 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; - var pos; - // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I - // considered using an actual Scanner, but this would complicate things. The - // scanner would need to know it was in a Doc Comment. Otherwise, it would then - // produce comments *inside* the doc comment. In the end it was just easier to - // write a simple scanner rather than go that route. - if (length >= "/** */".length) { - if (content.charCodeAt(start) === 47 /* slash */ && - content.charCodeAt(start + 1) === 42 /* asterisk */ && - content.charCodeAt(start + 2) === 42 /* asterisk */ && - content.charCodeAt(start + 3) !== 42 /* asterisk */) { + var result; + // Check for /** (JSDoc opening part) + if (content.charCodeAt(start) === 47 /* slash */ && + content.charCodeAt(start + 1) === 42 /* asterisk */ && + content.charCodeAt(start + 2) === 42 /* asterisk */ && + content.charCodeAt(start + 3) !== 42 /* asterisk */) { + // + 3 for leading /**, - 5 in total for /** */ + scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var canParseTag = true; var seenAsterisk = true; - for (pos = start + "/**".length; pos < end;) { - var ch = content.charCodeAt(pos); - pos++; - if (ch === 64 /* at */ && canParseTag) { - parseTag(); - // Once we parse out a tag, we cannot keep parsing out tags on this line. - canParseTag = false; - continue; - } - if (ts.isLineBreak(ch)) { - // After a line break, we can parse a tag, and we haven't seen as asterisk - // on the next line yet. - canParseTag = true; - seenAsterisk = false; - continue; - } - if (ts.isWhiteSpace(ch)) { - // Whitespace doesn't affect any of our parsing. - continue; - } - // Ignore the first asterisk on a line. - if (ch === 42 /* asterisk */) { - if (seenAsterisk) { - // If we've already seen an asterisk, then we can no longer parse a tag - // on this line. + nextJSDocToken(); + while (token !== 1 /* EndOfFileToken */) { + switch (token) { + case 55 /* AtToken */: + if (canParseTag) { + parseTag(); + } + // This will take us to the end of the line, so it's OK to parse a tag on the next pass through the loop + seenAsterisk = false; + break; + case 4 /* NewLineTrivia */: + // After a line break, we can parse a tag, and we haven't seen an asterisk on the next line yet + canParseTag = true; + seenAsterisk = false; + break; + case 37 /* AsteriskToken */: + if (seenAsterisk) { + // If we've already seen an asterisk, then we can no longer parse a tag on this line + canParseTag = false; + } + // Ignore the first asterisk on a line + seenAsterisk = true; + break; + case 69 /* Identifier */: + // Anything else is doc comment text. We can't do anything with it. Because it + // wasn't a tag, we can no longer parse a tag on this line until we hit the next + // line break. canParseTag = false; - } - seenAsterisk = true; - continue; + break; + case 1 /* EndOfFileToken */: + break; } - // Anything else is doc comment text. We can't do anything with it. Because it - // wasn't a tag, we can no longer parse a tag on this line until we hit the next - // line break. - canParseTag = false; + nextJSDocToken(); } - } + result = createJSDocComment(); + }); } - return createJSDocComment(); + return result; function createJSDocComment() { if (!tags) { return undefined; } - var result = createNode(268 /* JSDocComment */, start); + var result = createNode(269 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } function skipWhitespace() { - while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { - pos++; + while (token === 5 /* WhitespaceTrivia */ || token === 4 /* NewLineTrivia */) { + nextJSDocToken(); } } function parseTag() { - ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(55 /* AtToken */, pos - 1); - atToken.end = pos; - var tagName = scanIdentifier(); + ts.Debug.assert(token === 55 /* AtToken */); + var atToken = createNode(55 /* AtToken */, scanner.getTokenPos()); + atToken.end = scanner.getTextPos(); + nextJSDocToken(); + var tagName = parseJSDocIdentifier(); if (!tagName) { return; } @@ -12317,10 +12555,10 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(269 /* JSDocTag */, atToken.pos); + var result = createNode(270 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; - return finishNode(result, pos); + return finishNode(result); } function addTag(tag) { if (tag) { @@ -12333,12 +12571,10 @@ var ts; } } function tryParseTypeExpression() { - skipWhitespace(); - if (content.charCodeAt(pos) !== 123 /* openBrace */) { + if (token !== 15 /* OpenBraceToken */) { return undefined; } - var typeExpression = parseJSDocTypeExpression(pos, end - pos); - pos = typeExpression.end; + var typeExpression = parseJSDocTypeExpression(); return typeExpression; } function handleParamTag(atToken, tagName) { @@ -12346,17 +12582,22 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (content.charCodeAt(pos) === 91 /* openBracket */) { - pos++; - skipWhitespace(); - name = scanIdentifier(); + // Looking for something like '[foo]' or 'foo' + if (parseOptionalToken(19 /* OpenBracketToken */)) { + name = parseJSDocIdentifier(); isBracketed = true; + // May have an optional default, e.g. '[foo = 42]' + if (parseOptionalToken(56 /* EqualsToken */)) { + parseExpression(); + } + parseExpected(20 /* CloseBracketToken */); } - else { - name = scanIdentifier(); + else if (token === 69 /* Identifier */) { + name = parseJSDocIdentifier(); } if (!name) { - parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); + parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + return undefined; } var preName, postName; if (typeExpression) { @@ -12368,84 +12609,82 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(270 /* JSDocParameterTag */, atToken.pos); + var result = createNode(271 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; result.typeExpression = typeExpression; result.postParameterName = postName; result.isBracketed = isBracketed; - return finishNode(result, pos); + return finishNode(result); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 271 /* JSDocReturnTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + if (ts.forEach(tags, function (t) { return t.kind === 272 /* JSDocReturnTag */; })) { + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(271 /* JSDocReturnTag */, atToken.pos); + var result = createNode(272 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); + return finishNode(result); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 272 /* JSDocTypeTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + if (ts.forEach(tags, function (t) { return t.kind === 273 /* JSDocTypeTag */; })) { + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(272 /* JSDocTypeTag */, atToken.pos); + var result = createNode(273 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); + return finishNode(result); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 273 /* JSDocTemplateTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + if (ts.forEach(tags, function (t) { return t.kind === 274 /* JSDocTemplateTag */; })) { + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + // Type parameter list looks like '@template T,U,V' var typeParameters = []; - typeParameters.pos = pos; + typeParameters.pos = scanner.getStartPos(); while (true) { - skipWhitespace(); - var startPos = pos; - var name_8 = scanIdentifier(); + var name_8 = parseJSDocIdentifier(); if (!name_8) { - parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); + parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(138 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(139 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; - finishNode(typeParameter, pos); + finishNode(typeParameter); typeParameters.push(typeParameter); - skipWhitespace(); - if (content.charCodeAt(pos) !== 44 /* comma */) { + if (token === 24 /* CommaToken */) { + nextJSDocToken(); + } + else { break; } - pos++; } - typeParameters.end = pos; - var result = createNode(273 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(274 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; - return finishNode(result, pos); + finishNode(result); + typeParameters.end = result.end; + return result; } - function scanIdentifier() { - var startPos = pos; - for (; pos < end; pos++) { - var ch = content.charCodeAt(pos); - if (pos === startPos && ts.isIdentifierStart(ch, 2 /* Latest */)) { - continue; - } - else if (pos > startPos && ts.isIdentifierPart(ch, 2 /* Latest */)) { - continue; - } - break; - } - if (startPos === pos) { + function nextJSDocToken() { + return token = scanner.scanJSDocToken(); + } + function parseJSDocIdentifier() { + if (token !== 69 /* Identifier */) { + parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(69 /* Identifier */, startPos); - result.text = content.substring(startPos, pos); - return finishNode(result, pos); + var pos = scanner.getTokenPos(); + var end = scanner.getTextPos(); + var result = createNode(69 /* Identifier */, pos); + result.text = content.substring(pos, end); + finishNode(result, end); + nextJSDocToken(); + return result; } } JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; @@ -12463,10 +12702,10 @@ 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, /*syntaxCursor*/ undefined, /*setParentNodes*/ true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind); } // 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. + // we do an update the original source file is considered unusable from that point onwards. // // This is because we do incremental parsing in-place. i.e. we take nodes from the old // tree and give them new positions and parents. From that point on, trusting the old @@ -12519,7 +12758,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, /*setParentNodes*/ true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -12578,7 +12817,7 @@ var ts; // We have an element that intersects the change range in some way. It may have its // start, or its end (or both) in the changed range. We want to adjust any part // that intersects such that the final tree is in a consistent state. i.e. all - // chlidren have spans within the span of their parent, and all siblings are ordered + // children have spans within the span of their parent, and all siblings are ordered // properly. // We may need to update both the 'pos' and the 'end' of the element. // If the 'pos' is before the start of the change, then we don't need to touch it. @@ -12598,7 +12837,7 @@ var ts; // -------------------ZZZ----------------- // // In this case, any element that started in the 'X' range will keep its position. - // However any element htat started after that will have their pos adjusted to be + // However any element that started after that will have their pos adjusted to be // at the end of the new range. i.e. any node that started in the 'Y' range will // be adjusted to have their start at the end of the 'Z' range. // @@ -12622,7 +12861,7 @@ var ts; // -------------------ZZZ----------------- // // In this case, any element that ended in the 'X' range will keep its position. - // However any element htat ended after that will have their pos adjusted to be + // However any element that ended after that will have their pos adjusted to be // at the end of the new range. i.e. any node that ended in the 'Y' range will // be adjusted to have their end at the end of the 'Z' range. if (element.end >= changeRangeOldEnd) { @@ -12642,12 +12881,12 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos = node.pos; + var pos_2 = node.pos; forEachChild(node, function (child) { - ts.Debug.assert(child.pos >= pos); - pos = child.end; + ts.Debug.assert(child.pos >= pos_2); + pos_2 = child.end; }); - ts.Debug.assert(pos <= node.end); + ts.Debug.assert(pos_2 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -12881,7 +13120,7 @@ var ts; if (position >= node.pos && position < node.end) { // Position was within this node. Keep searching deeper to find the node. forEachChild(node, visitNode, visitArray); - // don't procede any futher in the search. + // don't proceed any further in the search. return true; } // position wasn't in this node, have to keep searching. @@ -12937,7 +13176,7 @@ var ts; var ModuleInstanceState = ts.ModuleInstanceState; var Reachability; (function (Reachability) { - Reachability[Reachability["Unintialized"] = 1] = "Unintialized"; + Reachability[Reachability["Uninitialized"] = 1] = "Uninitialized"; Reachability[Reachability["Reachable"] = 2] = "Reachable"; Reachability[Reachability["Unreachable"] = 4] = "Unreachable"; Reachability[Reachability["ReportedUnreachable"] = 8] = "ReportedUnreachable"; @@ -12952,17 +13191,17 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 218 /* InterfaceDeclaration */ || node.kind === 219 /* TypeAliasDeclaration */) { + if (node.kind === 219 /* InterfaceDeclaration */ || node.kind === 220 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 225 /* ImportDeclaration */ || node.kind === 224 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { + else if ((node.kind === 226 /* ImportDeclaration */ || node.kind === 225 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 222 /* ModuleBlock */) { - var state = 0 /* NonInstantiated */; + else if (node.kind === 223 /* ModuleBlock */) { + var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { case 0 /* NonInstantiated */: @@ -12970,17 +13209,17 @@ var ts; return false; case 2 /* ConstEnumOnly */: // child is const enum only - record state and continue searching - state = 2 /* ConstEnumOnly */; + state_1 = 2 /* ConstEnumOnly */; return false; case 1 /* Instantiated */: // child is instantiated - record state and stop - state = 1 /* Instantiated */; + state_1 = 1 /* Instantiated */; return true; } }); - return state; + return state_1; } - else if (node.kind === 221 /* ModuleDeclaration */) { + else if (node.kind === 222 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -13090,7 +13329,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 221 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 222 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -13103,7 +13342,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -13115,21 +13354,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 145 /* Constructor */: + case 146 /* Constructor */: return "__constructor"; - case 153 /* FunctionType */: - case 148 /* CallSignature */: + case 154 /* FunctionType */: + case 149 /* CallSignature */: return "__call"; - case 154 /* ConstructorType */: - case 149 /* ConstructSignature */: + case 155 /* ConstructorType */: + case 150 /* ConstructSignature */: return "__new"; - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: return "__index"; - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return "__export"; - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -13144,9 +13383,18 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 216 /* FunctionDeclaration */: - case 217 /* ClassDeclaration */: + case 217 /* FunctionDeclaration */: + case 218 /* ClassDeclaration */: return node.flags & 512 /* Default */ ? "default" : undefined; + case 265 /* JSDocFunctionType */: + return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; + case 140 /* Parameter */: + // Parameters with names are handled at the top of this function. Parameters + // without names can only come from JSDocFunctionTypes. + ts.Debug.assert(node.parent.kind === 265 /* JSDocFunctionType */); + var functionType = node.parent; + var index = ts.indexOf(functionType.parameters, node); + return "p" + index; } } function getDisplayName(node) { @@ -13197,18 +13445,18 @@ var ts; } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { if (declaration.flags & 512 /* Default */) { - message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message_1, getDisplayName(declaration))); }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message_1, getDisplayName(node))); symbol = createSymbol(0 /* None */, name); } } @@ -13220,9 +13468,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 2 /* Export */; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 233 /* ExportSpecifier */ || (node.kind === 224 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 234 /* ExportSpecifier */ || (node.kind === 225 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -13245,7 +13493,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 131072 /* ExportContext */)) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 8192 /* ExportContext */)) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -13263,7 +13511,7 @@ var ts; // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. function bindChildren(node) { - // Before we recurse into a node's chilren, we first save the existing parent, container + // Before we recurse into a node's children, we first save the existing parent, container // and block-container. Then after we pop out of processing the children, we restore // these saved values. var saveParent = parent; @@ -13286,7 +13534,7 @@ var ts; // Finally, if this is a block-container, then we clear out any existing .locals object // it may contain within it. This happens in incremental scenarios. Because we can be // reusing a node from a previous compilation, that node may have had 'locals' created - // for it. We must clear this so we don't accidently move any stale data forward from + // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. var containerFlags = getContainerFlags(node); if (containerFlags & 1 /* IsContainer */) { @@ -13308,13 +13556,13 @@ var ts; var kind = node.kind; var flags = node.flags; // reset all reachability check related flags on node (for incremental scenarios) - flags &= ~1572864 /* ReachabilityCheckFlags */; + flags &= ~98304 /* ReachabilityCheckFlags */; // reset all emit helper flags on node (for incremental scenarios) - flags &= ~62914560 /* EmitHelperFlags */; - if (kind === 218 /* InterfaceDeclaration */) { + flags &= ~3932160 /* EmitHelperFlags */; + if (kind === 219 /* InterfaceDeclaration */) { seenThisKeyword = false; } - var saveState = kind === 251 /* SourceFile */ || kind === 222 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); + var saveState = kind === 252 /* SourceFile */ || kind === 223 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -13325,28 +13573,31 @@ var ts; hasExplicitReturn = false; labelStack = labelIndexMap = implicitLabels = undefined; } + if (ts.isInJavaScriptFile(node) && node.jsDocComment) { + bind(node.jsDocComment); + } bindReachableStatement(node); if (currentReachabilityState === 2 /* Reachable */ && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { - flags |= 524288 /* HasImplicitReturn */; + flags |= 32768 /* HasImplicitReturn */; if (hasExplicitReturn) { - flags |= 1048576 /* HasExplicitReturn */; + flags |= 65536 /* HasExplicitReturn */; } } - if (kind === 218 /* InterfaceDeclaration */) { - flags = seenThisKeyword ? flags | 262144 /* ContainsThis */ : flags & ~262144 /* ContainsThis */; + if (kind === 219 /* InterfaceDeclaration */) { + flags = seenThisKeyword ? flags | 16384 /* ContainsThis */ : flags & ~16384 /* ContainsThis */; } - if (kind === 251 /* SourceFile */) { + if (kind === 252 /* SourceFile */) { if (hasClassExtends) { - flags |= 4194304 /* HasClassExtends */; + flags |= 262144 /* HasClassExtends */; } if (hasDecorators) { - flags |= 8388608 /* HasDecorators */; + flags |= 524288 /* HasDecorators */; } if (hasParameterDecorators) { - flags |= 16777216 /* HasParamDecorators */; + flags |= 1048576 /* HasParamDecorators */; } if (hasAsyncFunctions) { - flags |= 33554432 /* HasAsyncFunctions */; + flags |= 2097152 /* HasAsyncFunctions */; } } node.flags = flags; @@ -13371,40 +13622,40 @@ var ts; return; } switch (node.kind) { - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: bindWhileStatement(node); break; - case 200 /* DoStatement */: + case 201 /* DoStatement */: bindDoStatement(node); break; - case 202 /* ForStatement */: + case 203 /* ForStatement */: bindForStatement(node); break; - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 199 /* IfStatement */: + case 200 /* IfStatement */: bindIfStatement(node); break; - case 207 /* ReturnStatement */: - case 211 /* ThrowStatement */: + case 208 /* ReturnStatement */: + case 212 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 206 /* BreakStatement */: - case 205 /* ContinueStatement */: + case 207 /* BreakStatement */: + case 206 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 212 /* TryStatement */: + case 213 /* TryStatement */: bindTryStatement(node); break; - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: bindSwitchStatement(node); break; - case 223 /* CaseBlock */: + case 224 /* CaseBlock */: bindCaseBlock(node); break; - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: bindLabeledStatement(node); break; default: @@ -13479,7 +13730,7 @@ var ts; function bindReturnOrThrow(n) { // bind expression (don't affect reachability) bind(n.expression); - if (n.kind === 207 /* ReturnStatement */) { + if (n.kind === 208 /* ReturnStatement */) { hasExplicitReturn = true; } currentReachabilityState = 4 /* Unreachable */; @@ -13488,7 +13739,7 @@ var ts; // call bind on label (don't affect reachability) bind(n.label); // for continue case touch label so it will be marked a used - var isValidJump = jumpToLabel(n.label, n.kind === 206 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); + var isValidJump = jumpToLabel(n.label, n.kind === 207 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); if (isValidJump) { currentReachabilityState = 4 /* Unreachable */; } @@ -13514,8 +13765,8 @@ var ts; // bind expression (don't affect reachability) bind(n.expression); bind(n.caseBlock); - var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 245 /* DefaultClause */; }); - // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 246 /* DefaultClause */; }); + // post switch state is unreachable if switch is exhaustive (has a default case ) and does not have fallthrough from the last case var postSwitchState = hasDefault && currentReachabilityState !== 2 /* Reachable */ ? 4 /* Unreachable */ : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); } @@ -13541,39 +13792,40 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 189 /* ClassExpression */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 156 /* TypeLiteral */: - case 168 /* ObjectLiteralExpression */: + case 190 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 169 /* ObjectLiteralExpression */: + case 157 /* TypeLiteral */: + case 261 /* JSDocRecordType */: return 1 /* IsContainer */; - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 216 /* FunctionDeclaration */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 221 /* ModuleDeclaration */: - case 251 /* SourceFile */: - case 219 /* TypeAliasDeclaration */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 217 /* FunctionDeclaration */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 222 /* ModuleDeclaration */: + case 252 /* SourceFile */: + case 220 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 247 /* CatchClause */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 223 /* CaseBlock */: + case 248 /* CatchClause */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 224 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 195 /* Block */: + case 196 /* 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' + // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following // example: // @@ -13608,38 +13860,40 @@ 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 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 189 /* ClassExpression */: - case 217 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 218 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 156 /* TypeLiteral */: - case 168 /* ObjectLiteralExpression */: - case 218 /* InterfaceDeclaration */: + case 157 /* TypeLiteral */: + case 169 /* ObjectLiteralExpression */: + case 219 /* InterfaceDeclaration */: + case 261 /* JSDocRecordType */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // 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 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 219 /* TypeAliasDeclaration */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 265 /* JSDocFunctionType */: + case 220 /* 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 @@ -13650,7 +13904,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 64 /* Static */ + return node.flags & 32 /* Static */ ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -13660,11 +13914,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 251 /* SourceFile */ ? node : node.body; - if (body.kind === 251 /* SourceFile */ || body.kind === 222 /* ModuleBlock */) { + var body = node.kind === 252 /* SourceFile */ ? node : node.body; + if (body.kind === 252 /* SourceFile */ || body.kind === 223 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 231 /* ExportDeclaration */ || stat.kind === 230 /* ExportAssignment */) { + if (stat.kind === 232 /* ExportDeclaration */ || stat.kind === 231 /* ExportAssignment */) { return true; } } @@ -13675,16 +13929,16 @@ var ts; // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 131072 /* ExportContext */; + node.flags |= 8192 /* ExportContext */; } else { - node.flags &= ~131072 /* ExportContext */; + node.flags &= ~8192 /* ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); @@ -13743,7 +13997,7 @@ var ts; continue; } var identifier = prop.name; - // ECMA-262 11.1.5 Object Initialiser + // ECMA-262 11.1.5 Object Initializer // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and // IsDataDescriptor(propId.descriptor) is true. @@ -13751,7 +14005,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 === 248 /* PropertyAssignment */ || prop.kind === 249 /* ShorthandPropertyAssignment */ || prop.kind === 144 /* MethodDeclaration */ + var currentKind = prop.kind === 249 /* PropertyAssignment */ || prop.kind === 250 /* ShorthandPropertyAssignment */ || prop.kind === 145 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -13773,10 +14027,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -13873,7 +14127,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 32768 /* OctalLiteral */) { + if (inStrictMode && node.isOctalLiteral) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -13936,17 +14190,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 251 /* SourceFile */: - case 222 /* ModuleBlock */: + case 252 /* SourceFile */: + case 223 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 195 /* Block */: + case 196 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -13976,7 +14230,7 @@ var ts; /* Strict mode checks */ case 69 /* Identifier */: return checkStrictModeIdentifier(node); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -14000,97 +14254,100 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return checkStrictModeCatchClause(node); - case 178 /* DeleteExpression */: + case 179 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 183 /* PostfixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 208 /* WithStatement */: + case 209 /* WithStatement */: return checkStrictModeWithStatement(node); - case 162 /* ThisType */: + case 163 /* ThisType */: seenThisKeyword = true; return; - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: return checkTypePredicate(node); - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 139 /* Parameter */: + case 140 /* Parameter */: return bindParameter(node); - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 262 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 248 /* PropertyAssignment */: - case 249 /* ShorthandPropertyAssignment */: + case 249 /* PropertyAssignment */: + case 250 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* 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 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 145 /* Constructor */: + case 146 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 146 /* GetAccessor */: + case 147 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 147 /* SetAccessor */: + case 148 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 265 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 156 /* TypeLiteral */: + case 157 /* TypeLiteral */: + case 261 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return bindFunctionExpression(node); - case 171 /* CallExpression */: + case 172 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 189 /* ClassExpression */: - case 217 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 218 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 224 /* ImportEqualsDeclaration */: - case 227 /* NamespaceImport */: - case 229 /* ImportSpecifier */: - case 233 /* ExportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 228 /* NamespaceImport */: + case 230 /* ImportSpecifier */: + case 234 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 226 /* ImportClause */: + case 227 /* ImportClause */: return bindImportClause(node); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return bindExportDeclaration(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return bindExportAssignment(node); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -14099,7 +14356,7 @@ var ts; if (parameterName && parameterName.kind === 69 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 162 /* ThisType */) { + if (parameterName && parameterName.kind === 163 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -14114,12 +14371,12 @@ var ts; bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } function bindExportAssignment(node) { - var boundExpression = node.kind === 230 /* ExportAssignment */ ? node.expression : node.right; + var boundExpression = node.kind === 231 /* ExportAssignment */ ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (boundExpression.kind === 69 /* Identifier */) { + else if (boundExpression.kind === 69 /* Identifier */ && node.kind === 231 /* ExportAssignment */) { // 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 */); } @@ -14162,17 +14419,24 @@ var ts; } function bindThisPropertyAssignment(node) { // Declare a 'member' in case it turns out the container was an ES5 class - if (container.kind === 176 /* FunctionExpression */ || container.kind === 216 /* FunctionDeclaration */) { + if (container.kind === 177 /* FunctionExpression */ || container.kind === 217 /* FunctionDeclaration */) { container.symbol.members = container.symbol.members || {}; - declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */ & ~4 /* Property */); } } function bindPrototypePropertyAssignment(node) { // We saw a node of the form 'x.prototype.y = z'. Declare a 'member' y on x if x was a function. // Look up the function in the local scope, since prototype assignments should // follow the function declaration - var classId = node.left.expression.expression; - var funcSymbol = container.locals[classId.text]; + var leftSideOfAssignment = node.left; + var classPrototype = leftSideOfAssignment.expression; + var constructorFunction = classPrototype.expression; + // Fix up parent pointers since we're going to use these nodes before we bind into them + leftSideOfAssignment.parent = node; + constructorFunction.parent = classPrototype; + classPrototype.parent = leftSideOfAssignment; + var funcSymbol = container.locals[constructorFunction.text]; if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */)) { return; } @@ -14181,12 +14445,12 @@ var ts; funcSymbol.members = {}; } // Declare the method/property - declareSymbol(funcSymbol.members, funcSymbol, node.left, 4 /* Property */, 107455 /* PropertyExcludes */); + declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4 /* Property */, 107455 /* PropertyExcludes */); } function bindCallExpression(node) { // We're only inspecting call expressions to detect CommonJS modules, so we can skip // this check if we've already seen the module indicator - if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + if (!file.commonJsModuleIndicator && ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ false)) { setCommonJsModuleIndicator(node); } } @@ -14199,7 +14463,7 @@ var ts; hasDecorators = true; } } - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -14323,12 +14587,12 @@ var ts; if (ts.hasProperty(labelIndexMap, name.text)) { return false; } - labelIndexMap[name.text] = labelStack.push(1 /* Unintialized */) - 1; + labelIndexMap[name.text] = labelStack.push(1 /* Uninitialized */) - 1; return true; } function pushImplicitLabel() { initializeReachabilityStateIfNecessary(); - var index = labelStack.push(1 /* Unintialized */) - 1; + var index = labelStack.push(1 /* Uninitialized */) - 1; implicitLabels.push(index); return index; } @@ -14350,7 +14614,7 @@ var ts; setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); } function setCurrentStateAtLabel(innerMergedState, outerState, label) { - if (innerMergedState === 1 /* Unintialized */) { + if (innerMergedState === 1 /* Uninitialized */) { if (label && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); } @@ -14369,7 +14633,7 @@ var ts; return false; } var stateAtLabel = labelStack[index]; - labelStack[index] = stateAtLabel === 1 /* Unintialized */ ? outerState : or(stateAtLabel, outerState); + labelStack[index] = stateAtLabel === 1 /* Uninitialized */ ? outerState : or(stateAtLabel, outerState); return true; } function checkUnreachable(node) { @@ -14377,13 +14641,13 @@ var ts; case 4 /* Unreachable */: var reportError = // report error on all statements except empty ones - (ts.isStatement(node) && node.kind !== 197 /* EmptyStatement */) || + (ts.isStatement(node) && node.kind !== 198 /* EmptyStatement */) || // report error on class declarations - node.kind === 217 /* ClassDeclaration */ || + node.kind === 218 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 221 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 222 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 220 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 221 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentReachabilityState = 8 /* ReportedUnreachable */; // unreachable code is reported if @@ -14397,8 +14661,8 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 196 /* VariableStatement */ || - ts.getCombinedNodeFlags(node.declarationList) & 24576 /* BlockScoped */ || + (node.kind !== 197 /* VariableStatement */ || + ts.getCombinedNodeFlags(node.declarationList) & 3072 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); @@ -14469,8 +14733,8 @@ var ts; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; - var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === 4 /* System */; + var modulekind = ts.getEmitModuleKind(compilerOptions); + var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); undefinedSymbol.declarations = []; @@ -14540,14 +14804,16 @@ var ts; // 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, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var globals = {}; var globalESSymbolConstructorSymbol; var getGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; + var globalReadonlyArrayType; var globalStringType; var globalNumberType; var globalBooleanType; @@ -14558,6 +14824,7 @@ var ts; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; + var anyReadonlyArrayType; var getGlobalClassDecoratorType; var getGlobalParameterDecoratorType; var getGlobalPropertyDecoratorType; @@ -14719,7 +14986,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 221 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 221 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 222 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 222 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -14739,13 +15006,13 @@ var ts; recordMergedSymbol(target, source); } else { - var message = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(source.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); + error(node.name ? node.name : node, message_2, symbolToString(source)); }); ts.forEach(target.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); + error(node.name ? node.name : node, message_2, symbolToString(source)); }); } } @@ -14778,8 +15045,8 @@ var ts; var moduleAugmentation = moduleName.parent; if (moduleAugmentation.symbol.valueDeclaration !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. - // its symbol already has accumulated information for all declarations - // so we need to add it just once - do the work only for first declaration + // its symbol already has accumulated information for all declarations + // so we need to add it just once - do the work only for first declaration ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1); return; } @@ -14787,15 +15054,22 @@ var ts; mergeSymbolTable(globals, moduleAugmentation.symbol.exports); } else { - // find a module that about to be augmented + // find a module that about to be augmented var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found); if (!mainModule) { return; } - // if module symbol has already been merged - it is safe to use it. - // otherwise clone it - mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); - mergeSymbol(mainModule, moduleAugmentation.symbol); + // obtain item referenced by 'export=' + mainModule = resolveExternalModuleSymbol(mainModule); + if (mainModule.flags & 1536 /* Namespace */) { + // if module symbol has already been merged - it is safe to use it. + // otherwise clone it + mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); + mergeSymbol(mainModule, moduleAugmentation.symbol); + } + else { + error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text); + } } } function addToSymbolTable(target, source, message) { @@ -14825,7 +15099,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function isGlobalSourceFile(node) { - return node.kind === 251 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 252 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -14851,9 +15125,9 @@ var ts; * @return a tuple of two symbols */ function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { - var constructoDeclaration = parameter.parent; + var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructoDeclaration.locals, parameterName, 107455 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 107455 /* Value */); var propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, 107455 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; @@ -14874,7 +15148,7 @@ var ts; if (declaration.pos <= usage.pos) { // declaration is before usage // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 214 /* VariableDeclaration */ || + return declaration.kind !== 215 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -14882,14 +15156,14 @@ var ts; return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 196 /* VariableStatement */ || - declaration.parent.parent.kind === 202 /* ForStatement */) { + if (declaration.parent.parent.kind === 197 /* VariableStatement */ || + declaration.parent.parent.kind === 203 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) return isSameScopeDescendentOf(usage, declaration, container); } - else if (declaration.parent.parent.kind === 204 /* ForOfStatement */ || - declaration.parent.parent.kind === 203 /* ForInStatement */) { + else if (declaration.parent.parent.kind === 205 /* ForOfStatement */ || + declaration.parent.parent.kind === 204 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = declaration.parent.parent.expression; return isSameScopeDescendentOf(usage, expression, container); @@ -14906,8 +15180,8 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 142 /* PropertyDeclaration */ && - (current.parent.flags & 64 /* Static */) === 0 && + current.parent.kind === 143 /* PropertyDeclaration */ && + (current.parent.flags & 32 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -14936,11 +15210,13 @@ var ts; // - Type parameters of a function are in scope in the entire function declaration, including the parameter // list and return type. However, local types are only in scope in the function body. // - parameters are only in the scope of function body - if (meaning & result.flags & 793056 /* Type */) { + // This restriction does not apply to JSDoc comment types because they are parented + // at a higher level than type parameters would normally be + if (meaning & result.flags & 793056 /* Type */ && lastLocation.kind !== 269 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 139 /* Parameter */ || - lastLocation.kind === 138 /* TypeParameter */ + lastLocation.kind === 140 /* Parameter */ || + lastLocation.kind === 139 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -14949,9 +15225,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 139 /* Parameter */ || + lastLocation.kind === 140 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 139 /* Parameter */); + result.valueDeclaration.kind === 140 /* Parameter */); } } if (useResult) { @@ -14963,12 +15239,12 @@ var ts; } } switch (location.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 251 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 252 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports["default"]) { @@ -14991,7 +15267,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 233 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 234 /* ExportSpecifier */)) { break; } } @@ -14999,20 +15275,20 @@ var ts; break loop; } break; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(location.flags & 64 /* Static */)) { + if (ts.isClassLike(location.parent) && !(location.flags & 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -15022,11 +15298,11 @@ var ts; } } break; - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { - if (lastLocation && lastLocation.flags & 64 /* Static */) { + if (lastLocation && lastLocation.flags & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. @@ -15035,7 +15311,7 @@ var ts; } break loop; } - if (location.kind === 189 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 190 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -15051,9 +15327,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 218 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 219 /* 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); @@ -15061,19 +15337,19 @@ var ts; } } break; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 176 /* FunctionExpression */: + case 177 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -15086,7 +15362,7 @@ var ts; } } break; - case 140 /* Decorator */: + case 141 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -15095,7 +15371,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 === 139 /* Parameter */) { + if (location.parent && location.parent.kind === 140 /* Parameter */) { location = location.parent; } // @@ -15171,8 +15447,8 @@ var ts; return true; } // No static member is present. - // Check if we're in an instance method and look for a relevant instance member. - if (location === container && !(location.flags & 64 /* Static */)) { + // Check if we're in an instance method and look for a relevant instance member. + if (location === container && !(location.flags & 32 /* Static */)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); @@ -15189,7 +15465,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 214 /* VariableDeclaration */), errorLocation)) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 215 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -15210,10 +15486,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 224 /* ImportEqualsDeclaration */) { + if (node.kind === 225 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 225 /* ImportDeclaration */) { + while (node && node.kind !== 226 /* ImportDeclaration */) { node = node.parent; } return node; @@ -15223,7 +15499,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 235 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 236 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -15236,7 +15512,7 @@ var ts; error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { - return resolveSymbol(moduleSymbol.exports["export="]) || resolveSymbol(moduleSymbol); + return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } return exportDefaultSymbol; } @@ -15325,17 +15601,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 226 /* ImportClause */: + case 227 /* ImportClause */: return getTargetOfImportClause(node); - case 227 /* NamespaceImport */: + case 228 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 229 /* ImportSpecifier */: + case 230 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 233 /* ExportSpecifier */: + case 234 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -15380,11 +15656,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 230 /* ExportAssignment */) { + if (node.kind === 231 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 233 /* ExportSpecifier */) { + else if (node.kind === 234 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -15397,7 +15673,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 224 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 225 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -15410,13 +15686,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 136 /* QualifiedName */) { + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 137 /* 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 === 224 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 225 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -15436,9 +15712,9 @@ var ts; return undefined; } } - else if (name.kind === 136 /* QualifiedName */ || name.kind === 169 /* PropertyAccessExpression */) { - var left = name.kind === 136 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 136 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 137 /* QualifiedName */ || name.kind === 170 /* PropertyAccessExpression */) { + var left = name.kind === 137 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 137 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -15487,7 +15763,7 @@ var ts; return getMergedSymbol(sourceFile.symbol); } if (moduleNotFoundError) { - // report errors only if it was requested + // report errors only if it was requested error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); } return undefined; @@ -15501,7 +15777,7 @@ var ts; // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may @@ -15514,8 +15790,8 @@ var ts; } return symbol; } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="]; + function hasExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="] !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -15624,7 +15900,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 145 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 146 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -15671,19 +15947,19 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; + if (stringIndexInfo) + type.stringIndexInfo = stringIndexInfo; + if (numberIndexInfo) + type.numberIndexInfo = numberIndexInfo; return type; } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -15695,17 +15971,17 @@ var ts; } } switch (location_1.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -15732,7 +16008,7 @@ var ts; function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) - // and if symbolfrom symbolTable or alias resolution matches the symbol, + // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && canQualifySymbol(symbolFromSymbolTable, meaning); @@ -15746,7 +16022,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 234 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -15783,7 +16059,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, 233 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 234 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -15856,7 +16132,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 251 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 252 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -15870,7 +16146,7 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 2 /* Export */) && + !(anyImportSyntax.flags & 1 /* Export */) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -15892,12 +16168,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 155 /* TypeQuery */) { + if (entityName.parent.kind === 156 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 136 /* QualifiedName */ || entityName.kind === 169 /* PropertyAccessExpression */ || - entityName.parent.kind === 224 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 137 /* QualifiedName */ || entityName.kind === 170 /* PropertyAccessExpression */ || + entityName.parent.kind === 225 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -15949,13 +16225,29 @@ var ts; } return result; } + function typePredicateToString(typePredicate, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function visibilityToString(flags) { + if (flags === 8 /* Private */) { + return "private"; + } + if (flags === 16 /* Protected */) { + return "protected"; + } + return "public"; + } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 161 /* ParenthesizedType */) { + while (node.kind === 162 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 219 /* TypeAliasDeclaration */) { + if (node.kind === 220 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -15963,7 +16255,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 222 /* ModuleBlock */ && + node.parent.kind === 223 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function getSymbolDisplayBuilder() { @@ -15974,10 +16266,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: return "(Anonymous class)"; - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -16065,16 +16357,10 @@ var ts; function writeType(type, flags) { // Write undefined/null type as any if (type.flags & 16777343 /* Intrinsic */) { - if (type.flags & 134217728 /* PredicateType */) { - buildTypePredicateDisplay(writer, type.predicate); - buildTypeDisplay(type.predicate.type, writer, enclosingDeclaration, flags, symbolStack); - } - else { - // 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" - : type.intrinsicName); - } + // 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" + : type.intrinsicName); } else if (type.flags & 33554432 /* ThisType */) { if (inObjectTypeLiteral) { @@ -16159,14 +16445,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_4 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_4); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_4, typeArguments, start, i, flags); writePunctuation(writer, 21 /* DotToken */); } } @@ -16228,11 +16514,11 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64 /* Static */; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 32 /* Static */; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 251 /* SourceFile */ || declaration.parent.kind === 222 /* ModuleBlock */; + return declaration.parent.kind === 252 /* SourceFile */ || declaration.parent.kind === 223 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -16246,19 +16532,38 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } - function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); - if (!declaration) { - // declaration might not be found if indexer was added from the contextual type. - // in this case use fallback name - return fallbackName; + function writeIndexSignature(info, keyword) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 127 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, keyword); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeType(info.type, 0 /* None */); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + } + function writePropertyWithModifiers(prop) { + if (isReadonlySymbol(prop)) { + writeKeyword(writer, 127 /* ReadonlyKeyword */); + writeSpace(writer); + } + buildSymbolDisplay(prop, writer); + if (prop.flags & 536870912 /* Optional */) { + writePunctuation(writer, 53 /* QuestionToken */); } - ts.Debug.assert(declaration.parameters.length !== 0); - return ts.declarationNameToString(declaration.parameters[0].name); } function writeLiteralType(type, flags) { var resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 15 /* OpenBraceToken */); writePunctuation(writer, 16 /* CloseBraceToken */); @@ -16304,34 +16609,8 @@ var ts; writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } - if (resolved.stringIndexType) { - // [x: string]: - writePunctuation(writer, 19 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 130 /* StringKeyword */); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.numberIndexType) { - // [x: number]: - writePunctuation(writer, 19 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 128 /* NumberKeyword */); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } + writeIndexSignature(resolved.stringIndexInfo, 131 /* StringKeyword */); + writeIndexSignature(resolved.numberIndexInfo, 129 /* NumberKeyword */); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -16339,20 +16618,14 @@ var ts; var signatures = getSignaturesOfType(t, 0 /* Call */); for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { var signature = signatures_1[_f]; - buildSymbolDisplay(p, writer); - if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); - } + writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } else { - buildSymbolDisplay(p, writer); - if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); - } + writePropertyWithModifiers(p); writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); @@ -16365,10 +16638,10 @@ var ts; inObjectTypeLiteral = saveInObjectTypeLiteral; } } - function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { + function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaration, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -16431,7 +16704,7 @@ var ts; } writePunctuation(writer, 18 /* CloseParenToken */); } - function buildTypePredicateDisplay(writer, predicate) { + function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } @@ -16441,6 +16714,7 @@ var ts; writeSpace(writer); writeKeyword(writer, 124 /* IsKeyword */); writeSpace(writer); + buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { @@ -16451,8 +16725,13 @@ var ts; writePunctuation(writer, 54 /* ColonToken */); } writeSpace(writer); - var returnType = getReturnTypeOfSignature(signature); - buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + if (signature.typePredicate) { + buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); + } + else { + var returnType = getReturnTypeOfSignature(signature); + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1 /* Construct */) { @@ -16474,6 +16753,7 @@ var ts; buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, + buildTypePredicateDisplay: buildTypePredicateDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, @@ -16493,74 +16773,74 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 166 /* BindingElement */: + case 167 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 214 /* VariableDeclaration */: + case 215 /* 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 221 /* ModuleDeclaration */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 216 /* FunctionDeclaration */: - case 220 /* EnumDeclaration */: - case 224 /* ImportEqualsDeclaration */: + case 222 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 217 /* FunctionDeclaration */: + case 221 /* EnumDeclaration */: + case 225 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_4 = getDeclarationContainer(node); + var parent_5 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedNodeFlags(node) & 2 /* Export */) && - !(node.kind !== 224 /* ImportEqualsDeclaration */ && parent_4.kind !== 251 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { - return isGlobalSourceFile(parent_4); + if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && + !(node.kind !== 225 /* ImportEqualsDeclaration */ && parent_5.kind !== 252 /* SourceFile */ && ts.isInAmbientContext(parent_5))) { + return isGlobalSourceFile(parent_5); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_4); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - if (node.flags & (16 /* Private */ | 32 /* Protected */)) { + return isDeclarationVisible(parent_5); + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + if (node.flags & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 145 /* Constructor */: - case 149 /* ConstructSignature */: - case 148 /* CallSignature */: - case 150 /* IndexSignature */: - case 139 /* Parameter */: - case 222 /* ModuleBlock */: - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 156 /* TypeLiteral */: - case 152 /* TypeReference */: - case 157 /* ArrayType */: - case 158 /* TupleType */: - case 159 /* UnionType */: - case 160 /* IntersectionType */: - case 161 /* ParenthesizedType */: + case 146 /* Constructor */: + case 150 /* ConstructSignature */: + case 149 /* CallSignature */: + case 151 /* IndexSignature */: + case 140 /* Parameter */: + case 223 /* ModuleBlock */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 157 /* TypeLiteral */: + case 153 /* TypeReference */: + case 158 /* ArrayType */: + case 159 /* TupleType */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: + case 162 /* 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 226 /* ImportClause */: - case 227 /* NamespaceImport */: - case 229 /* ImportSpecifier */: + case 227 /* ImportClause */: + case 228 /* NamespaceImport */: + case 230 /* ImportSpecifier */: return false; // Type parameters are always visible - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: // Source file is always visible - case 251 /* SourceFile */: + case 252 /* SourceFile */: return true; // Export assignments do not create name bindings outside the module - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -16569,10 +16849,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 230 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 231 /* 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 === 233 /* ExportSpecifier */) { + else if (node.parent.kind === 234 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -16664,16 +16944,27 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - // Parent chain: - // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 214 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + while (node) { + switch (node.kind) { + case 215 /* VariableDeclaration */: + case 216 /* VariableDeclarationList */: + case 230 /* ImportSpecifier */: + case 229 /* NamedImports */: + case 228 /* NamespaceImport */: + case 227 /* ImportClause */: + node = node.parent; + break; + default: + return node.parent; + } + } } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 // Every class automatically contains a static property member named 'prototype', // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. // It is an error to explicitly declare a static property member with the name 'prototype'. - var classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); + var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } // Return the type of the given property in the given type, or undefined if no such property exists @@ -16697,7 +16988,7 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -16705,7 +16996,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 137 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 138 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); } // Return the inferred type for a binding element function getTypeForBindingElement(declaration) { @@ -16725,7 +17016,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 164 /* ObjectBindingPattern */) { + if (pattern.kind === 165 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_10)) { @@ -16771,13 +17062,53 @@ var ts; } return type; } + function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + var jsDocType = getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (jsDocType) { + return getTypeFromTypeNode(jsDocType); + } + } + function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + // First, see if this node has an @type annotation on it directly. + var typeTag = ts.getJSDocTypeTag(declaration); + if (typeTag && typeTag.typeExpression) { + return typeTag.typeExpression.type; + } + if (declaration.kind === 215 /* VariableDeclaration */ && + declaration.parent.kind === 216 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 197 /* VariableStatement */) { + // @type annotation might have been on the variable statement, try that instead. + var annotation = ts.getJSDocTypeTag(declaration.parent.parent); + if (annotation && annotation.typeExpression) { + return annotation.typeExpression.type; + } + } + else if (declaration.kind === 140 /* Parameter */) { + // If it's a parameter, see if the parent has a jsdoc comment with an @param + // annotation. + var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type; + } + } + return undefined; + } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { + if (declaration.flags & 134217728 /* JavaScriptFile */) { + // If this is a variable in a JavaScript file, then use the JSDoc type (if it has + // one as its type), otherwise fallback to the below standard TS codepaths to + // try to figure it out. + var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (type && type !== unknownType) { + return type; + } + } // A variable declared in a for..in statement is always of type string - if (declaration.parent.parent.kind === 203 /* ForInStatement */) { + if (declaration.parent.parent.kind === 204 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 204 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 205 /* 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, @@ -16791,11 +17122,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 139 /* Parameter */) { + if (declaration.kind === 140 /* 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 === 147 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 146 /* GetAccessor */); + if (func.kind === 148 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 147 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -16811,7 +17142,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 249 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 250 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -16867,7 +17198,7 @@ var ts; return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 190 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 191 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -16883,7 +17214,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 164 /* ObjectBindingPattern */ + return pattern.kind === 165 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -16905,10 +17236,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - if (declaration.kind === 248 /* PropertyAssignment */) { - return type; - } - if (type.flags & 134217728 /* PredicateType */ && (declaration.kind === 142 /* PropertyDeclaration */ || declaration.kind === 141 /* PropertySignature */)) { + if (declaration.kind === 249 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -16918,7 +17246,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 139 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 140 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -16933,21 +17261,21 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 247 /* CatchClause */) { + if (declaration.parent.kind === 248 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 230 /* ExportAssignment */) { + if (declaration.kind === 231 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle module.exports = expr - if (declaration.kind === 184 /* BinaryExpression */) { - return links.type = checkExpression(declaration.right); + if (declaration.kind === 185 /* BinaryExpression */) { + return links.type = getUnionType(ts.map(symbol.declarations, function (decl) { return checkExpressionCached(decl.right); })); } - if (declaration.kind === 169 /* PropertyAccessExpression */) { + if (declaration.kind === 170 /* PropertyAccessExpression */) { // Declarations only exist for property access expressions for certain // special assignment kinds - if (declaration.parent.kind === 184 /* BinaryExpression */) { + if (declaration.parent.kind === 185 /* BinaryExpression */) { // Handle exports.p = expr or this.p = expr or className.prototype.method = expr return links.type = checkExpressionCached(declaration.parent.right); } @@ -16977,7 +17305,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 146 /* GetAccessor */) { + if (accessor.kind === 147 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -16993,9 +17321,9 @@ var ts; if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 146 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 147 /* SetAccessor */); - var type; + var getter = ts.getDeclarationOfKind(symbol, 147 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 148 /* SetAccessor */); + var type = void 0; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -17023,7 +17351,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 146 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 147 /* 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)); } } @@ -17123,9 +17451,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 217 /* ClassDeclaration */ || node.kind === 189 /* ClassExpression */ || - node.kind === 216 /* FunctionDeclaration */ || node.kind === 176 /* FunctionExpression */ || - node.kind === 144 /* MethodDeclaration */ || node.kind === 177 /* ArrowFunction */) { + if (node.kind === 218 /* ClassDeclaration */ || node.kind === 190 /* ClassExpression */ || + node.kind === 217 /* FunctionDeclaration */ || node.kind === 177 /* FunctionExpression */ || + node.kind === 145 /* MethodDeclaration */ || node.kind === 178 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -17135,7 +17463,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, 218 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 219 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -17144,8 +17472,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 218 /* InterfaceDeclaration */ || node.kind === 217 /* ClassDeclaration */ || - node.kind === 189 /* ClassExpression */ || node.kind === 219 /* TypeAliasDeclaration */) { + if (node.kind === 219 /* InterfaceDeclaration */ || node.kind === 218 /* ClassDeclaration */ || + node.kind === 190 /* ClassExpression */ || node.kind === 220 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -17172,8 +17500,8 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { - var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); } return signatures; } @@ -17285,7 +17613,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 218 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 219 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -17317,8 +17645,8 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 218 /* InterfaceDeclaration */) { - if (declaration.flags & 262144 /* ContainsThis */) { + if (declaration.kind === 219 /* InterfaceDeclaration */) { + if (declaration.flags & 16384 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -17373,7 +17701,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 219 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 220 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -17406,7 +17734,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 138 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 139 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -17457,16 +17785,16 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: case 103 /* VoidKeyword */: - case 163 /* StringLiteralType */: + case 164 /* StringLiteralType */: return true; - case 157 /* ArrayType */: + case 158 /* ArrayType */: return isIndependentType(node.elementType); - case 152 /* TypeReference */: + case 153 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -17479,7 +17807,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 145 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 146 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -17493,19 +17821,19 @@ var ts; // Returns true if the class or interface member given by the symbol is free of "this" references. The // function may return false for symbols that are actually free of "this" references because it is not // feasible to perform a complete analysis in all cases. In particular, property members with types - // inferred from their initializers and function members with inferred return types are convervatively + // inferred from their initializers and function members with inferred return types are conservatively // assumed not to be free of "this" references. function isIndependentMember(symbol) { if (symbol.declarations && symbol.declarations.length === 1) { var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -17544,8 +17872,8 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); + type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); } return type; } @@ -17560,15 +17888,15 @@ var ts; var members = source.symbol.members; var callSignatures = source.declaredCallSignatures; var constructSignatures = source.declaredConstructSignatures; - var stringIndexType = source.declaredStringIndexType; - var numberIndexType = source.declaredNumberIndexType; + var stringIndexInfo = source.declaredStringIndexInfo; + var numberIndexInfo = source.declaredNumberIndexInfo; if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); - stringIndexType = instantiateType(source.declaredStringIndexType, mapper); - numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); + numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); } var baseTypes = getBaseTypes(source); if (baseTypes.length) { @@ -17582,11 +17910,11 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); + stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0 /* String */); + numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1 /* Number */); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); @@ -17598,25 +17926,26 @@ var ts; type.typeArguments : ts.concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); @@ -17649,7 +17978,7 @@ var ts; var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { @@ -17715,45 +18044,50 @@ var ts; } return result || emptyArray; } - function getUnionIndexType(types, kind) { + function getUnionIndexInfo(types, kind) { var indexTypes = []; + var isAnyReadonly = false; for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { var type = types_1[_i]; - var indexType = getIndexTypeOfType(type, kind); - if (!indexType) { + var indexInfo = getIndexInfoOfType(type, kind); + if (!indexInfo) { return undefined; } - indexTypes.push(indexType); + indexTypes.push(indexInfo.type); + isAnyReadonly = isAnyReadonly || indexInfo.isReadonly; } - return getUnionType(indexTypes); + return createIndexInfo(getUnionType(indexTypes), isAnyReadonly); } function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). var callSignatures = getUnionSignatures(type.types, 0 /* Call */); var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); - var stringIndexType = getUnionIndexType(type.types, 0 /* String */); - var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); + var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } + function intersectIndexInfos(info1, info2) { + return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); + } function resolveIntersectionTypeMembers(type) { // The members and properties collections are empty for intersection types. To get all properties of an // intersection type use getPropertiesOfType (only the language service uses this). var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexType = undefined; - var numberIndexType = undefined; + var stringIndexInfo = undefined; + var numberIndexInfo = undefined; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); - stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0 /* String */)); - numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1 /* Number */)); + stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0 /* String */)); + numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; @@ -17761,17 +18095,17 @@ var ts; var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); var constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); - var stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); - var numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0 /* String */), type.mapper); + var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1 /* Number */), type.mapper); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; var callSignatures = getSignaturesOfSymbol(members["__call"]); var constructSignatures = getSignaturesOfSymbol(members["__new"]); - var stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - var numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); + var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { // Combinations of function, class, enum and module @@ -17792,8 +18126,8 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } - var numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexType); + var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; + setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list @@ -17912,7 +18246,7 @@ var ts; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 /* Private */ | 32 /* Protected */))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */))) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -18002,17 +18336,48 @@ var ts; function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } - function getIndexTypeOfStructuredType(type, kind) { + function getIndexInfoOfStructuredType(type, kind) { if (type.flags & 130048 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; + return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } } + function getIndexTypeOfStructuredType(type, kind) { + var info = getIndexInfoOfStructuredType(type, kind); + return info && info.type; + } + // Return the indexing info of the given kind in the given type. Creates synthetic union index types when necessary and + // maps primitive types and type parameters are to their apparent types. + function getIndexInfoOfType(type, kind) { + return getIndexInfoOfStructuredType(getApparentType(type), kind); + } // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. function getIndexTypeOfType(type, kind) { return getIndexTypeOfStructuredType(getApparentType(type), kind); } + function getImplicitIndexTypeOfType(type, kind) { + if (isObjectLiteralType(type)) { + var propTypes = []; + for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + if (kind === 0 /* String */ || isNumericLiteralName(prop.name)) { + propTypes.push(getTypeOfSymbol(prop)); + } + } + return getUnionType(propTypes); + } + return undefined; + } + function getTypeParametersFromJSDocTemplate(declaration) { + if (declaration.flags & 134217728 /* JavaScriptFile */) { + var templateTag = ts.getJSDocTemplateTag(declaration); + if (templateTag) { + return getTypeParametersFromDeclaration(templateTag.typeParameters); + } + } + return undefined; + } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(typeParameterDeclarations) { @@ -18035,6 +18400,20 @@ var ts; return result; } function isOptionalParameter(node) { + if (node.flags & 134217728 /* JavaScriptFile */) { + if (node.type && node.type.kind === 264 /* JSDocOptionalType */) { + return true; + } + var paramTag = ts.getCorrespondingJSDocParameterTag(node); + if (paramTag) { + if (paramTag.isBracketed) { + return true; + } + if (paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 264 /* JSDocOptionalType */; + } + } + } if (ts.hasQuestionToken(node)) { return true; } @@ -18067,15 +18446,22 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 145 /* Constructor */ ? + var classType = declaration.kind === 146 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : - declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; + declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : + getTypeParametersFromJSDocTemplate(declaration); var parameters = []; var hasStringLiterals = false; var minArgumentCount = -1; - for (var i = 0, n = declaration.parameters.length; i < n; i++) { + var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var returnType = undefined; + var typePredicate = undefined; + // If this is a JSDoc construct signature, then skip the first parameter in the + // parameter list. The first parameter represents the return type of the construct + // signature. + for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature @@ -18084,7 +18470,7 @@ var ts; paramSymbol = resolvedSymbol; } parameters.push(paramSymbol); - if (param.type && param.type.kind === 163 /* StringLiteralType */) { + if (param.type && param.type.kind === 164 /* StringLiteralType */) { hasStringLiterals = true; } if (param.initializer || param.questionToken || param.dotDotDotToken) { @@ -18100,25 +18486,37 @@ var ts; if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; } - var returnType; - if (classType) { + if (isJSConstructSignature) { + minArgumentCount--; + returnType = getTypeFromTypeNode(declaration.parameters[0].type); + } + else if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 152 /* TypePredicate */) { + typePredicate = createTypePredicateFromTypePredicateNode(declaration.type); + } } else { + if (declaration.flags & 134217728 /* JavaScriptFile */) { + var type = getReturnTypeFromJSDocComment(declaration); + if (type && type !== unknownType) { + returnType = type; + } + } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 146 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 147 /* SetAccessor */); + if (declaration.kind === 147 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 148 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -18129,19 +18527,20 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 265 /* JSDocFunctionType */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -18171,7 +18570,7 @@ var ts; if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } - var type; + var type = void 0; if (signature.target) { type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); } @@ -18228,7 +18627,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 === 145 /* Constructor */ || signature.declaration.kind === 149 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 146 /* Constructor */ || signature.declaration.kind === 150 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -18242,7 +18641,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 129 /* NumberKeyword */ : 131 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -18258,18 +18657,22 @@ var ts; } return undefined; } - function getIndexTypeOfSymbol(symbol, kind) { + function createIndexInfo(type, isReadonly, declaration) { + return { type: type, isReadonly: isReadonly, declaration: declaration }; + } + function getIndexInfoOfSymbol(symbol, kind) { var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType - : undefined; + if (declaration) { + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, (declaration.flags & 64 /* Readonly */) !== 0, declaration); + } + return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 138 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 139 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; - while (type && type.flags & 512 /* TypeParameter */ && !ts.contains(checked, type)) { + while (type && !(type.flags & 33554432 /* ThisType */) && type.flags & 512 /* TypeParameter */ && !ts.contains(checked, type)) { if (type === target) { return true; } @@ -18298,7 +18701,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 138 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 139 /* TypeParameter */).parent); } function getTypeListId(types) { if (types) { @@ -18393,18 +18796,68 @@ var ts; } return getDeclaredTypeOfSymbol(symbol); } + function getTypeReferenceName(node) { + switch (node.kind) { + case 153 /* TypeReference */: + return node.typeName; + case 263 /* JSDocTypeReference */: + return node.name; + case 192 /* ExpressionWithTypeArguments */: + // We only support expressions that are simple qualified names. For other + // expressions this produces undefined. + if (ts.isSupportedExpressionWithTypeArguments(node)) { + return node.expression; + } + } + return undefined; + } + function resolveTypeReferenceName(node, typeReferenceName) { + if (!typeReferenceName) { + return unknownSymbol; + } + return resolveEntityName(typeReferenceName, 793056 /* Type */) || unknownSymbol; + } + function getTypeReferenceType(node, symbol) { + if (symbol === unknownSymbol) { + return unknownType; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); + } + if (symbol.flags & 107455 /* Value */ && node.kind === 263 /* JSDocTypeReference */) { + // A JSDocTypeReference may have resolved to a value (as opposed to a type). In + // that case, the type of this reference is just the type of the value we resolved + // to. + return getTypeOfSymbol(symbol); + } + return getTypeFromNonGenericTypeReference(node, symbol); + } function getTypeFromTypeReference(node) { 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 === 152 /* TypeReference */ ? node.typeName : - ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : - undefined; - var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; - var type = symbol === unknownSymbol ? unknownType : - symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + var symbol = void 0; + var type = void 0; + if (node.kind === 263 /* JSDocTypeReference */) { + var typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(node, typeReferenceName); + type = getTypeReferenceType(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + else { + // We only support expressions that are simple qualified names. For other expressions this produces undefined. + var typeNameOrExpression = node.kind === 153 /* TypeReference */ ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; + type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + } // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; @@ -18429,9 +18882,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: return declaration; } } @@ -18669,12 +19122,28 @@ var ts; } return links.resolvedType; } + function getTypeFromJSDocVariadicType(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var type = getTypeFromTypeNode(node.type); + links.resolvedType = type ? createArrayType(type) : unknownType; + } + return links.resolvedType; + } + function getTypeFromJSDocTupleType(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var types = ts.map(node.types, getTypeFromTypeNode); + links.resolvedType = createTupleType(types); + } + return links.resolvedType; + } function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 218 /* InterfaceDeclaration */)) { - if (!(container.flags & 64 /* Static */) && - (container.kind !== 145 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { + if (parent && (ts.isClassLike(parent) || parent.kind === 219 /* InterfaceDeclaration */)) { + if (!(container.flags & 32 /* Static */) && + (container.kind !== 146 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -18688,68 +19157,68 @@ var ts; } return links.resolvedType; } - function getPredicateType(node) { - return createPredicateType(getSymbolOfNode(node), createTypePredicateFromTypePredicateNode(node)); - } - function createPredicateType(symbol, predicate) { - var type = createType(8 /* Boolean */ | 134217728 /* PredicateType */); - type.symbol = symbol; - type.predicate = predicate; - return type; - } - function getTypeFromPredicateTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getPredicateType(node); - } - return links.resolvedType; - } function getTypeFromTypeNode(node) { switch (node.kind) { case 117 /* AnyKeyword */: + case 254 /* JSDocAllType */: + case 255 /* JSDocUnknownType */: return anyType; - case 130 /* StringKeyword */: + case 131 /* StringKeyword */: return stringType; - case 128 /* NumberKeyword */: + case 129 /* NumberKeyword */: return numberType; case 120 /* BooleanKeyword */: return booleanType; - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: return esSymbolType; case 103 /* VoidKeyword */: return voidType; - case 162 /* ThisType */: + case 163 /* ThisType */: return getTypeFromThisTypeNode(node); - case 163 /* StringLiteralType */: + case 164 /* StringLiteralType */: return getTypeFromStringLiteralTypeNode(node); - case 152 /* TypeReference */: + case 153 /* TypeReference */: + case 263 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 151 /* TypePredicate */: - return getTypeFromPredicateTypeNode(node); - case 191 /* ExpressionWithTypeArguments */: + case 152 /* TypePredicate */: + return booleanType; + case 192 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 157 /* ArrayType */: + case 158 /* ArrayType */: + case 256 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 158 /* TupleType */: + case 159 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 159 /* UnionType */: + case 160 /* UnionType */: + case 257 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); - case 160 /* IntersectionType */: + case 161 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: + case 259 /* JSDocNullableType */: + case 260 /* JSDocNonNullableType */: + case 267 /* JSDocConstructorType */: + case 268 /* JSDocThisType */: + case 264 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 156 /* TypeLiteral */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 157 /* TypeLiteral */: + case 265 /* JSDocFunctionType */: + case 261 /* JSDocRecordType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 69 /* Identifier */: - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); + case 258 /* JSDocTupleType */: + return getTypeFromJSDocTupleType(node); + case 266 /* JSDocVariadicType */: + return getTypeFromJSDocVariadicType(node); default: return unknownType; } @@ -18853,6 +19322,7 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { // First create a fresh set of type parameters, then include a mapping from the old to the // new type parameters in the mapper function. Finally store this mapper in the new type @@ -18864,7 +19334,10 @@ var ts; tp.mapper = mapper; } } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper); + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -18928,37 +19401,36 @@ var ts; if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); } - if (type.flags & 134217728 /* PredicateType */) { - var predicate = type.predicate; - return createPredicateType(type.symbol, cloneTypePredicate(predicate, mapper)); - } } return type; } + function instantiateIndexInfo(info, mapper) { + return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); + } // 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 !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return node.operatorToken.kind === 52 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 248 /* PropertyAssignment */: + case 249 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -19045,18 +19517,48 @@ var ts; } var sourceReturnType = getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions - if (targetReturnType.flags & 134217728 /* PredicateType */ && targetReturnType.predicate.kind === 1 /* Identifier */) { - if (!(sourceReturnType.flags & 134217728 /* PredicateType */)) { + if (target.typePredicate) { + if (source.typePredicate) { + result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes); + } + else if (ts.isIdentifierTypePredicate(target.typePredicate)) { if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); } return 0 /* False */; } } - result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + else { + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + } } return result; } + function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) { + if (source.kind !== target.kind) { + if (reportErrors) { + errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return 0 /* False */; + } + if (source.kind === 1 /* Identifier */) { + var sourceIdentifierPredicate = source; + var targetIdentifierPredicate = target; + if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { + if (reportErrors) { + errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return 0 /* False */; + } + } + var related = compareTypes(source.type, target.type, reportErrors); + if (related === 0 /* False */ && reportErrors) { + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return related; + } function isImplementationCompatibleWithOverload(implementation, overload) { var erasedSource = getErasedSignature(implementation); var erasedTarget = getErasedSignature(overload); @@ -19171,33 +19673,6 @@ var ts; return -1 /* True */; } if (source.flags & 8 /* Boolean */ && target.flags & 8 /* Boolean */) { - if (source.flags & 134217728 /* PredicateType */ && target.flags & 134217728 /* PredicateType */) { - var sourcePredicate = source; - var targetPredicate = target; - if (sourcePredicate.predicate.kind !== targetPredicate.predicate.kind) { - if (reportErrors) { - reportError(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - if (sourcePredicate.predicate.kind === 1 /* Identifier */) { - var sourceIdentifierPredicate = sourcePredicate.predicate; - var targetIdentifierPredicate = targetPredicate.predicate; - if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { - if (reportErrors) { - reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - } - var related = isRelatedTo(sourcePredicate.predicate.type, targetPredicate.predicate.type, reportErrors, headMessage); - if (related === 0 /* False */ && reportErrors) { - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return related; - } return -1 /* True */; } if (source.flags & 1048576 /* FreshObjectLiteral */) { @@ -19311,7 +19786,7 @@ var ts; if (type.flags & 80896 /* ObjectType */) { var resolved = resolveStructuredTypeMembers(type); if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || - resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + resolved.stringIndexInfo || resolved.numberIndexInfo || getPropertyOfType(type, name)) { return true; } } @@ -19326,7 +19801,7 @@ var ts; return false; } function hasExcessProperties(source, target, reportErrors) { - if (!(target.flags & 67108864 /* ObjectLiteralPatternWithComputedProperties */) && someConstituentTypeHasKind(target, 80896 /* ObjectType */)) { + if (!(target.flags & 67108864 /* ObjectLiteralPatternWithComputedProperties */) && maybeTypeOfKind(target, 80896 /* ObjectType */)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -19480,9 +19955,9 @@ var ts; if (result) { result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, 0 /* String */, reportErrors); if (result) { - result &= numberIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, 1 /* Number */, reportErrors); } } } @@ -19525,23 +20000,23 @@ var ts; else if (!(targetProp.flags & 134217728 /* Prototype */)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 16 /* Private */ || targetPropFlags & 16 /* Private */) { + if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 16 /* Private */ && targetPropFlags & 16 /* Private */) { + if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 /* Private */ ? source : target), typeToString(sourcePropFlags & 16 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); } } return 0 /* False */; } } - else if (targetPropFlags & 32 /* Protected */) { + else if (targetPropFlags & 16 /* Protected */) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; + var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); @@ -19549,7 +20024,7 @@ var ts; return 0 /* False */; } } - else if (sourcePropFlags & 32 /* Protected */) { + else if (sourcePropFlags & 16 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -19614,43 +20089,41 @@ var ts; } var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length && - isAbstractConstructorType(source) && !isAbstractConstructorType(target)) { - // An abstract constructor type is not assignable to a non-abstract constructor type - // as it would otherwise be possible to new an abstract class. Note that the assignablity - // check we perform for an extends clause excludes construct signatures from the target, - // so this check never proceeds. - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { + if (isAbstractConstructorType(source) && !isAbstractConstructorType(target)) { + // An abstract constructor type is not assignable to a non-abstract constructor type + // as it would otherwise be possible to new an abstract class. Note that the assignability + // check we perform for an extends clause excludes construct signatures from the target, + // so this check never proceeds. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { + return 0 /* False */; } - return 0 /* False */; } var result = -1 /* True */; var saveErrorInfo = errorInfo; outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { var t = targetSignatures_1[_i]; - if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { - // Only elaborate errors from the first failure - var shouldElaborateErrors = reportErrors; - for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { - var s = sourceSignatures_1[_a]; - if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { - var related = signatureRelatedTo(s, t, shouldElaborateErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; - } - shouldElaborateErrors = false; - } + // Only elaborate errors from the first failure + var shouldElaborateErrors = reportErrors; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; + var related = signatureRelatedTo(s, t, shouldElaborateErrors); + if (related) { + result &= related; + errorInfo = saveErrorInfo; + continue outer; } - // don't elaborate the primitive apparent types (like Number) - // because the actual primitives will have already been reported. - if (shouldElaborateErrors) { - reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); - } - return 0 /* False */; + shouldElaborateErrors = false; } + if (shouldElaborateErrors) { + reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); + } + return 0 /* False */; } return result; } @@ -19676,80 +20149,70 @@ var ts; } return result; } - function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0 /* String */, source, target); - } - var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { - if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: string]: any } = { property: 12 };` - return -1 /* True */; - } - var sourceType = getIndexTypeOfType(source, 0 /* String */); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + function eachPropertyRelatedTo(source, target, kind, reportErrors) { + var result = -1 /* True */; + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (kind === 0 /* String */ || isNumericLiteralName(prop.name)) { + var related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); + } + return 0 /* False */; } - return 0 /* False */; + result &= related; } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; } - return -1 /* True */; + return result; } - function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1 /* Number */, source, target); + function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { + var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors); + if (!related && reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); } - var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { - if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: number]: any } = { property: 12 };` - return -1 /* True */; - } - var sourceStringType = getIndexTypeOfType(source, 0 /* String */); - var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; - } - var related; - if (sourceStringType && sourceNumberType) { - // If we know for sure we're testing both string and numeric index types then only report errors from the second one - related = isRelatedTo(sourceStringType, targetType, /*reportErrors*/ false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; - } - return -1 /* True */; + return related; } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { + function indexTypesRelatedTo(source, originalSource, target, kind, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(source, target, kind); + } + var targetInfo = getIndexInfoOfType(target, kind); + if (!targetInfo || ((targetInfo.type.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */))) { + // Index signature of type any permits assignment from everything but primitives return -1 /* True */; } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); + var sourceInfo = getIndexInfoOfType(source, kind) || + kind === 1 /* Number */ && getIndexInfoOfType(source, 0 /* String */); + if (sourceInfo) { + return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); + } + if (isObjectLiteralType(source)) { + var related = -1 /* True */; + if (kind === 0 /* String */) { + var sourceNumberInfo = getIndexInfoOfType(source, 1 /* Number */); + if (sourceNumberInfo) { + related = indexInfoRelatedTo(sourceNumberInfo, targetInfo, reportErrors); + } + } + if (related) { + related &= eachPropertyRelatedTo(source, targetInfo.type, kind, reportErrors); + } + return related; + } + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0 /* False */; + } + function indexTypesIdenticalTo(source, target, indexKind) { + var targetInfo = getIndexInfoOfType(target, indexKind); + var sourceInfo = getIndexInfoOfType(source, indexKind); + if (!sourceInfo && !targetInfo) { + return -1 /* True */; + } + if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) { + return isRelatedTo(sourceInfo.type, targetInfo.type); } return 0 /* False */; } @@ -19772,6 +20235,29 @@ var ts; } return -1 /* True */; } + function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { + if (!sourceSignature.declaration || !targetSignature.declaration) { + return true; + } + var sourceAccessibility = sourceSignature.declaration.flags & (8 /* Private */ | 16 /* Protected */); + var targetAccessibility = targetSignature.declaration.flags & (8 /* Private */ | 16 /* Protected */); + // A public, protected and private signature is assignable to a private signature. + if (targetAccessibility === 8 /* Private */) { + return true; + } + // A public and protected signature is assignable to a protected signature. + if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + return true; + } + // Only a public signature is assignable to public signature. + if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + return true; + } + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility)); + } + return false; + } } // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { @@ -19817,8 +20303,8 @@ var ts; if (sourceProp === targetProp) { return -1 /* True */; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 /* Private */ | 32 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 /* Private */ | 32 /* Protected */); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (8 /* Private */ | 16 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (8 /* Private */ | 16 /* Protected */); if (sourcePropAccessibility !== targetPropAccessibility) { return 0 /* False */; } @@ -19832,6 +20318,9 @@ var ts; return 0 /* False */; } } + if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { + return 0 /* False */; + } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { @@ -19941,8 +20430,10 @@ var ts; return type.flags & 4096 /* Reference */ && type.target === globalArrayType; } function isArrayLikeType(type) { - // A type is array-like if it is not the undefined or null type and if it is assignable to any[] - return !(type.flags & (32 /* Undefined */ | 64 /* Null */)) && isTypeAssignableTo(type, anyArrayType); + // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, + // or if it is not the undefined or null type and if it is assignable to ReadonlyArray + return type.flags & 4096 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || + !(type.flags & (32 /* Undefined */ | 64 /* Null */)) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isTupleLikeType(type) { return !!getPropertyOfType(type, "0"); @@ -19957,6 +20448,15 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192 /* Tuple */); } + /** + * Return true if type was inferred from an object literal or written as an object type literal + * with no call or construct signatures. + */ + function isObjectLiteralType(type) { + return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */)) !== 0 && + getSignaturesOfType(type, 0 /* Call */).length === 0 && + getSignaturesOfType(type, 1 /* Construct */).length === 0; + } function getRegularTypeOfObjectLiteral(type) { if (type.flags & 1048576 /* FreshObjectLiteral */) { var regularType = type.regularType; @@ -19967,8 +20467,8 @@ var ts; regularType.properties = type.properties; regularType.callSignatures = type.callSignatures; regularType.constructSignatures = type.constructSignatures; - regularType.stringIndexType = type.stringIndexType; - regularType.numberIndexType = type.numberIndexType; + regularType.stringIndexInfo = type.stringIndexInfo; + regularType.numberIndexInfo = type.numberIndexInfo; type.regularType = regularType; } return regularType; @@ -19993,22 +20493,15 @@ var ts; } members[p.name] = p; }); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndexInfo = getIndexInfoOfType(type, 0 /* String */); + var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); } function getWidenedType(type) { - if (type.flags & 140509184 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } - if (type.flags & 134217728 /* PredicateType */) { - return booleanType; - } if (type.flags & 524288 /* ObjectLiteral */) { return getWidenedTypeOfObjectLiteral(type); } @@ -20074,22 +20567,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 139 /* Parameter */: + case 140 /* 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 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -20156,6 +20649,7 @@ var ts; var targetStack; var depth = 0; var inferiority = 0; + var visited = {}; inferFromTypes(source, target); function isInProcess(source, target) { for (var i = 0; i < depth; i++) { @@ -20173,7 +20667,7 @@ var ts; // type, and for each such target constituent type infer from the type to itself. // When inferring from a type to itself we effectively find all type parameter // occurrences within that type and infer themselves as their type arguments. - var matchingTypes; + var matchingTypes = void 0; for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var t = _a[_i]; if (typeIdenticalToSomeType(t, source.types)) { @@ -20230,11 +20724,6 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (source.flags & 134217728 /* PredicateType */ && target.flags & 134217728 /* PredicateType */) { - if (source.predicate.kind === target.predicate.kind) { - inferFromTypes(source.predicate.type, target.predicate.type); - } - } 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; @@ -20246,7 +20735,7 @@ var ts; else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; - var typeParameter; + var typeParameter = void 0; // First infer to each type in union or intersection that isn't a type parameter for (var _b = 0, targetTypes_2 = targetTypes; _b < targetTypes_2.length; _b++) { var t = targetTypes_2[_b]; @@ -20269,7 +20758,7 @@ var ts; } } else if (source.flags & 49152 /* UnionOrIntersection */) { - // Source is a union or intersection type, infer from each consituent type + // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _c = 0, sourceTypes_3 = sourceTypes; _c < sourceTypes_3.length; _c++) { var sourceType = sourceTypes_3[_c]; @@ -20289,6 +20778,11 @@ var ts; if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { return; } + var key = source.id + "," + target.id; + if (ts.hasProperty(visited, key)) { + return; + } + visited[key] = true; if (depth === 0) { sourceStack = []; targetStack = []; @@ -20299,9 +20793,7 @@ var ts; inferFromProperties(source, target); inferFromSignatures(source, target, 0 /* Call */); inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + inferFromIndexTypes(source, target); depth--; } } @@ -20328,14 +20820,29 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate && source.typePredicate.kind === target.typePredicate.kind) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } - function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); + function inferFromIndexTypes(source, target) { + var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); + if (targetStringIndexType) { + var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || + getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); + inferFromTypes(sourceIndexType, targetStringIndexType); + } + } + var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); + if (targetNumberIndexType) { + var sourceIndexType = getIndexTypeOfType(source, 1 /* Number */) || + getIndexTypeOfType(source, 0 /* String */) || + getImplicitIndexTypeOfType(source, 1 /* Number */); + if (sourceIndexType) { + inferFromTypes(sourceIndexType, targetNumberIndexType); } } } @@ -20426,10 +20933,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 155 /* TypeQuery */: + case 156 /* TypeQuery */: return true; case 69 /* Identifier */: - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: node = node.parent; continue; default: @@ -20471,55 +20978,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: - case 167 /* ArrayLiteralExpression */: - case 168 /* ObjectLiteralExpression */: - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 174 /* TypeAssertionExpression */: - case 192 /* AsExpression */: - case 175 /* ParenthesizedExpression */: - case 182 /* PrefixUnaryExpression */: - case 178 /* DeleteExpression */: - case 181 /* AwaitExpression */: - case 179 /* TypeOfExpression */: - case 180 /* VoidExpression */: - case 183 /* PostfixUnaryExpression */: - case 187 /* YieldExpression */: - case 185 /* ConditionalExpression */: - case 188 /* SpreadElementExpression */: - case 195 /* Block */: - case 196 /* VariableStatement */: - case 198 /* ExpressionStatement */: - case 199 /* IfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 207 /* ReturnStatement */: - case 208 /* WithStatement */: - case 209 /* SwitchStatement */: - case 244 /* CaseClause */: - case 245 /* DefaultClause */: - case 210 /* LabeledStatement */: - case 211 /* ThrowStatement */: - case 212 /* TryStatement */: - case 247 /* CatchClause */: - case 236 /* JsxElement */: - case 237 /* JsxSelfClosingElement */: - case 241 /* JsxAttribute */: - case 242 /* JsxSpreadAttribute */: - case 238 /* JsxOpeningElement */: - case 243 /* JsxExpression */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: + case 168 /* ArrayLiteralExpression */: + case 169 /* ObjectLiteralExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 175 /* TypeAssertionExpression */: + case 193 /* AsExpression */: + case 176 /* ParenthesizedExpression */: + case 183 /* PrefixUnaryExpression */: + case 179 /* DeleteExpression */: + case 182 /* AwaitExpression */: + case 180 /* TypeOfExpression */: + case 181 /* VoidExpression */: + case 184 /* PostfixUnaryExpression */: + case 188 /* YieldExpression */: + case 186 /* ConditionalExpression */: + case 189 /* SpreadElementExpression */: + case 196 /* Block */: + case 197 /* VariableStatement */: + case 199 /* ExpressionStatement */: + case 200 /* IfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 208 /* ReturnStatement */: + case 209 /* WithStatement */: + case 210 /* SwitchStatement */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: + case 211 /* LabeledStatement */: + case 212 /* ThrowStatement */: + case 213 /* TryStatement */: + case 248 /* CatchClause */: + case 237 /* JsxElement */: + case 238 /* JsxSelfClosingElement */: + case 242 /* JsxAttribute */: + case 243 /* JsxSpreadAttribute */: + case 239 /* JsxOpeningElement */: + case 244 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -20531,7 +21038,7 @@ var ts; // Only narrow when symbol is variable of type any or an object, union, or type parameter type if (node && symbol.flags & 3 /* Variable */) { if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { - var declaration = ts.getDeclarationOfKind(symbol, 214 /* VariableDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 215 /* VariableDeclaration */); var top_1 = declaration && getDeclarationContainer(declaration); var originalType = type; var nodeStack = []; @@ -20539,13 +21046,13 @@ var ts; var child = node; node = node.parent; switch (node.kind) { - case 199 /* IfStatement */: - case 185 /* ConditionalExpression */: - case 184 /* BinaryExpression */: + case 200 /* IfStatement */: + case 186 /* ConditionalExpression */: + case 185 /* BinaryExpression */: nodeStack.push({ node: node, child: child }); break; - case 251 /* SourceFile */: - case 221 /* ModuleDeclaration */: + case 252 /* SourceFile */: + case 222 /* ModuleDeclaration */: // Stop at the first containing file or module declaration break loop; } @@ -20553,23 +21060,23 @@ var ts; break; } } - var nodes; + var nodes = void 0; while (nodes = nodeStack.pop()) { var node_1 = nodes.node, child = nodes.child; switch (node_1.kind) { - case 199 /* IfStatement */: + case 200 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node_1.expression) { type = narrowType(type, node_1.expression, /*assumeTrue*/ child === node_1.thenStatement); } break; - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node_1.condition) { type = narrowType(type, node_1.condition, /*assumeTrue*/ child === node_1.whenTrue); } break; - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node_1.right) { if (node_1.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { @@ -20597,7 +21104,7 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 179 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + if (expr.left.kind !== 180 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; @@ -20684,7 +21191,7 @@ var ts; } if (!targetType) { // Target type is type of construct signature - var constructSignatures; + var constructSignatures = void 0; if (rightType.flags & 2048 /* Interface */) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } @@ -20721,42 +21228,30 @@ var ts; } return originalType; } - function narrowTypeByTypePredicate(type, expr, assumeTrue) { + function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { if (type.flags & 1 /* Any */) { return type; } - var signature = getResolvedSignature(expr); - var predicateType = getReturnTypeOfSignature(signature); - if (!predicateType || !(predicateType.flags & 134217728 /* PredicateType */)) { + var signature = getResolvedSignature(callExpression); + var predicate = signature.typePredicate; + if (!predicate) { return type; } - var predicate = predicateType.predicate; if (ts.isIdentifierTypePredicate(predicate)) { - var callExpression = expr; if (callExpression.arguments[predicate.parameterIndex] && getSymbolAtTypePredicatePosition(callExpression.arguments[predicate.parameterIndex]) === symbol) { return getNarrowedType(type, predicate.type, assumeTrue); } } else { - var expression = skipParenthesizedNodes(expr.expression); - return narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue); + var invokedExpression = skipParenthesizedNodes(callExpression.expression); + return narrowTypeByThisTypePredicate(type, predicate, invokedExpression, assumeTrue); } return type; } - function narrowTypeByTypePredicateMember(type, expr, assumeTrue) { - if (type.flags & 1 /* Any */) { - return type; - } - var memberType = getTypeOfExpression(expr); - if (!(memberType.flags & 134217728 /* PredicateType */)) { - return type; - } - return narrowTypeByThisTypePredicate(type, memberType.predicate, expr, assumeTrue); - } - function narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue) { - if (expression.kind === 170 /* ElementAccessExpression */ || expression.kind === 169 /* PropertyAccessExpression */) { - var accessExpression = expression; + function narrowTypeByThisTypePredicate(type, predicate, invokedExpression, assumeTrue) { + if (invokedExpression.kind === 171 /* ElementAccessExpression */ || invokedExpression.kind === 170 /* PropertyAccessExpression */) { + var accessExpression = invokedExpression; var possibleIdentifier = skipParenthesizedNodes(accessExpression.expression); if (possibleIdentifier.kind === 69 /* Identifier */ && getSymbolAtTypePredicatePosition(possibleIdentifier) === symbol) { return getNarrowedType(type, predicate.type, assumeTrue); @@ -20768,8 +21263,7 @@ var ts; expr = skipParenthesizedNodes(expr); switch (expr.kind) { case 69 /* Identifier */: - case 169 /* PropertyAccessExpression */: - case 136 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: return getSymbolOfEntityNameOrPropertyAccessExpression(expr); } } @@ -20777,11 +21271,11 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 171 /* CallExpression */: + case 172 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -20796,20 +21290,17 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: if (expr.operator === 49 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; - case 170 /* ElementAccessExpression */: - case 169 /* PropertyAccessExpression */: - return narrowTypeByTypePredicateMember(type, expr, assumeTrue); } return type; } } function skipParenthesizedNodes(expression) { - while (expression.kind === 175 /* ParenthesizedExpression */) { + while (expression.kind === 176 /* ParenthesizedExpression */) { expression = expression.expression; } return expression; @@ -20824,23 +21315,40 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 177 /* ArrowFunction */) { + if (container.kind === 178 /* 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); } } - if (node.parserContextFlags & 8 /* Await */) { - getNodeLinks(container).flags |= 4096 /* CaptureArguments */; - getNodeLinks(node).flags |= 2048 /* LexicalArguments */; + if (node.flags & 33554432 /* AwaitContext */) { + getNodeLinks(container).flags |= 8192 /* CaptureArguments */; } } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); } + var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); + // Due to the emit for class decorators, any reference to the class from inside of the class body + // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind + // behavior of class names in ES6. + if (languageVersion === 2 /* ES6 */ + && localOrExportSymbol.flags & 32 /* Class */ + && localOrExportSymbol.valueDeclaration.kind === 218 /* ClassDeclaration */ + && ts.nodeIsDecorated(localOrExportSymbol.valueDeclaration)) { + var container = ts.getContainingClass(node); + while (container !== undefined) { + if (container === localOrExportSymbol.valueDeclaration && container.name !== node) { + getNodeLinks(container).flags |= 524288 /* ClassWithBodyScopedClassBinding */; + getNodeLinks(node).flags |= 1048576 /* BodyScopedClassBinding */; + break; + } + container = ts.getContainingClass(container); + } + } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); - checkBlockScopedBindingCapturedInLoop(node, symbol); - return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); + checkNestedBlockScopedBinding(node, symbol); + return getNarrowedTypeOfSymbol(localOrExportSymbol, node); } function isInsideFunction(node, threshold) { var current = node; @@ -20852,52 +21360,79 @@ var ts; } return false; } - function checkBlockScopedBindingCapturedInLoop(node, symbol) { + function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 247 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 248 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check // if there is anything function like between declaration and use-site (is binding/class is captured in function). // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) - var container; - if (symbol.flags & 32 /* Class */) { - // get parent of class declaration - container = getClassLikeDeclarationOfSymbol(symbol).parent; - } - else { - // nesting structure: - // (variable declaration or binding element) -> variable declaration list -> container - container = symbol.valueDeclaration; - while (container.kind !== 215 /* VariableDeclarationList */) { - container = container.parent; - } - // get the parent of variable declaration list - container = container.parent; - if (container.kind === 196 /* VariableStatement */) { - // if parent is variable statement - get its parent - container = container.parent; - } - } - var inFunction = isInsideFunction(node.parent, container); + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + var usedInFunction = isInsideFunction(node.parent, container); var current = container; + var containedInIterationStatement = false; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - if (inFunction) { - getNodeLinks(current).flags |= 65536 /* LoopWithBlockScopedBindingCapturedInFunction */; - } - // mark value declaration so during emit they can have a special handling - getNodeLinks(symbol.valueDeclaration).flags |= 16384 /* BlockScopedBindingInLoop */; + containedInIterationStatement = true; break; } current = current.parent; } + if (containedInIterationStatement) { + if (usedInFunction) { + // mark iteration statement as containing block-scoped binding captured in some function + getNodeLinks(current).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + } + // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. + // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. + if (container.kind === 203 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 216 /* VariableDeclarationList */).parent === container && + isAssignedInBodyOfForStatement(node, container)) { + getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; + } + // set 'declared inside loop' bit on the block-scoped binding + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* BlockScopedBindingInLoop */; + } + if (usedInFunction) { + getNodeLinks(symbol.valueDeclaration).flags |= 131072 /* CapturedBlockScopedBinding */; + } + } + function isAssignedInBodyOfForStatement(node, container) { + var current = node; + // skip parenthesized nodes + while (current.parent.kind === 176 /* ParenthesizedExpression */) { + current = current.parent; + } + // check if node is used as LHS in some assignment expression + var isAssigned = false; + if (current.parent.kind === 185 /* BinaryExpression */) { + isAssigned = current.parent.left === current && ts.isAssignmentOperator(current.parent.operatorToken.kind); + } + if ((current.parent.kind === 183 /* PrefixUnaryExpression */ || current.parent.kind === 184 /* PostfixUnaryExpression */)) { + var expr = current.parent; + isAssigned = expr.operator === 41 /* PlusPlusToken */ || expr.operator === 42 /* MinusMinusToken */; + } + if (!isAssigned) { + return false; + } + // at this point we know that node is the target of assignment + // now check that modification happens inside the statement part of the ForStatement + while (current !== container) { + if (current === container.statement) { + return true; + } + else { + current = current.parent; + } + } + return false; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 142 /* PropertyDeclaration */ || container.kind === 145 /* Constructor */) { + if (container.kind === 143 /* PropertyDeclaration */ || container.kind === 146 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -20905,38 +21440,93 @@ var ts; getNodeLinks(container).flags |= 4 /* CaptureThis */; } } + function findFirstSuperCall(n) { + if (ts.isSuperCallExpression(n)) { + return n; + } + else if (ts.isFunctionLike(n)) { + return undefined; + } + return ts.forEachChild(n, findFirstSuperCall); + } + /** + * Return a cached result if super-statement is already found. + * Otherwise, find a super statement in a given constructor function and cache the result in the node-links of the constructor + * + * @param constructor constructor-function to look for super statement + */ + function getSuperCallInConstructor(constructor) { + var links = getNodeLinks(constructor); + // Only trying to find super-call if we haven't yet tried to find one. Once we try, we will record the result + if (links.hasSuperCall === undefined) { + links.superCall = findFirstSuperCall(constructor.body); + links.hasSuperCall = links.superCall ? true : false; + } + return links.superCall; + } + /** + * Check if the given class-declaration extends null then return true. + * Otherwise, return false + * @param classDecl a class declaration to check if it extends null + */ + function classDeclarationExtendsNull(classDecl) { + var classSymbol = getSymbolOfNode(classDecl); + var classInstanceType = getDeclaredTypeOfSymbol(classSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType); + return baseConstructorType === nullType; + } 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, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; + if (container.kind === 146 /* Constructor */) { + var containingClassDecl = container.parent; + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + // If a containing class does not have extends clause or the class extends null + // skip checking whether super statement is called before "this" accessing. + if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { + var superCall = getSuperCallInConstructor(container); + // We should give an error in the following cases: + // - No super-call + // - "this" is accessing before super-call. + // i.e super(this) + // this.x; super(); + // We want to make sure that super-call is done before accessing "this" so that + // "this" is not accessed as a parameter of the super-call. + if (!superCall || superCall.end > node.pos) { + // In ES6, super inside constructor of class-declaration has to precede "this" accessing + error(node, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); + } + } + } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 177 /* ArrowFunction */) { + if (container.kind === 178 /* 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 221 /* ModuleDeclaration */: + case 222 /* 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 220 /* EnumDeclaration */: + case 221 /* 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 145 /* Constructor */: + case 146 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - if (container.flags & 64 /* Static */) { + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + if (container.flags & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -20945,40 +21535,55 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 64 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 32 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } - // If this is a function in a JS file, it might be a class method. Check if it's the RHS - // of a x.prototype.y = function [name]() { .... } - if (ts.isInJavaScriptFile(node) && container.kind === 176 /* FunctionExpression */) { - if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { - // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') - var className = container.parent // x.protoype.y = f - .left // x.prototype.y - .expression // x.prototype - .expression; // x - var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - return getInferredClassType(classSymbol); + if (ts.isInJavaScriptFile(node)) { + var type = getTypeForThisExpressionFromJSDoc(container); + if (type && type !== unknownType) { + return type; + } + // If this is a function in a JS file, it might be a class method. Check if it's the RHS + // of a x.prototype.y = function [name]() { .... } + if (container.kind === 177 /* FunctionExpression */) { + if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { + // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') + var className = container.parent // x.prototype.y = f + .left // x.prototype.y + .expression // x.prototype + .expression; // x + var classSymbol = checkExpression(className).symbol; + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + return getInferredClassType(classSymbol); + } } } } return anyType; } + function getTypeForThisExpressionFromJSDoc(node) { + var typeTag = ts.getJSDocTypeTag(node); + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 265 /* JSDocFunctionType */) { + var jsDocFunctionType = typeTag.typeExpression.type; + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 268 /* JSDocThisType */) { + return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); + } + } + } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 139 /* Parameter */) { + if (n.kind === 140 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 171 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 172 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; if (!isCallExpression) { // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 177 /* ArrowFunction */) { + while (container && container.kind === 178 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } @@ -20992,16 +21597,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 137 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 138 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 137 /* ComputedPropertyName */) { + if (current && current.kind === 138 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 168 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 169 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -21009,20 +21614,84 @@ var ts; } return unknownType; } - if ((container.flags & 64 /* Static */) || isCallExpression) { + if ((container.flags & 32 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; } else { nodeCheckFlag = 256 /* SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; + // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. + // This is due to the fact that we emit the body of an async function inside of a generator function. As generator + // functions cannot reference `super`, we emit a helper inside of the method body, but outside of the generator. This helper + // uses an arrow function, which is permitted to reference `super`. + // + // There are two primary ways we can access `super` from within an async method. The first is getting the value of a property + // or indexed access on super, either as part of a right-hand-side expression or call expression. The second is when setting the value + // of a property or indexed access, either as part of an assignment expression or destructuring assignment. + // + // The simplest case is reading a value, in which case we will emit something like the following: + // + // // ts + // ... + // async asyncMethod() { + // let x = await super.asyncMethod(); + // return x; + // } + // ... + // + // // js + // ... + // asyncMethod() { + // const _super = name => super[name]; + // return __awaiter(this, arguments, Promise, function *() { + // let x = yield _super("asyncMethod").call(this); + // return x; + // }); + // } + // ... + // + // The more complex case is when we wish to assign a value, especially as part of a destructuring assignment. As both cases + // are legal in ES6, but also likely less frequent, we emit the same more complex helper for both scenarios: + // + // // ts + // ... + // async asyncMethod(ar: Promise) { + // [super.a, super.b] = await ar; + // } + // ... + // + // // js + // ... + // asyncMethod(ar) { + // const _super = (function (geti, seti) { + // const cache = Object.create(null); + // return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } }); + // })(name => super[name], (name, value) => super[name] = value); + // return __awaiter(this, arguments, Promise, function *() { + // [_super("a").value, _super("b").value] = yield ar; + // }); + // } + // ... + // + // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. + // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment + // while a property access can. + if (container.kind === 145 /* MethodDeclaration */ && container.flags & 256 /* Async */) { + if (ts.isSuperPropertyOrElementAccess(node.parent) && isAssignmentTarget(node.parent)) { + getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + } + else { + getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + } + } 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 (container.parent.kind === 168 /* ObjectLiteralExpression */) { + if (container.parent.kind === 169 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -21042,7 +21711,7 @@ var ts; } return unknownType; } - if (container.kind === 145 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 146 /* 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; @@ -21057,7 +21726,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 145 /* Constructor */; + return container.kind === 146 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -21065,21 +21734,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 168 /* ObjectLiteralExpression */) { - if (container.flags & 64 /* Static */) { - return container.kind === 144 /* MethodDeclaration */ || - container.kind === 143 /* MethodSignature */ || - container.kind === 146 /* GetAccessor */ || - container.kind === 147 /* SetAccessor */; + if (ts.isClassLike(container.parent) || container.parent.kind === 169 /* ObjectLiteralExpression */) { + if (container.flags & 32 /* Static */) { + return container.kind === 145 /* MethodDeclaration */ || + container.kind === 144 /* MethodSignature */ || + container.kind === 147 /* GetAccessor */ || + container.kind === 148 /* SetAccessor */; } else { - return container.kind === 144 /* MethodDeclaration */ || - container.kind === 143 /* MethodSignature */ || - container.kind === 146 /* GetAccessor */ || - container.kind === 147 /* SetAccessor */ || - container.kind === 142 /* PropertyDeclaration */ || - container.kind === 141 /* PropertySignature */ || - container.kind === 145 /* Constructor */; + return container.kind === 145 /* MethodDeclaration */ || + container.kind === 144 /* MethodSignature */ || + container.kind === 147 /* GetAccessor */ || + container.kind === 148 /* SetAccessor */ || + container.kind === 143 /* PropertyDeclaration */ || + container.kind === 142 /* PropertySignature */ || + container.kind === 146 /* Constructor */; } } } @@ -21121,7 +21790,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 139 /* Parameter */) { + if (declaration.kind === 140 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -21154,7 +21823,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 139 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 140 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -21165,8 +21834,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 === 145 /* Constructor */ || - functionDecl.kind === 146 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 147 /* SetAccessor */))) { + functionDecl.kind === 146 /* Constructor */ || + functionDecl.kind === 147 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 148 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -21188,7 +21857,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 173 /* TaggedTemplateExpression */) { + if (template.parent.kind === 174 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -21261,10 +21930,6 @@ var ts; function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } - // Return true if the given contextual type provides an index signature of the given kind - function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); - } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one // exists. Otherwise, it is the type of the string index signature in T, if one exists. @@ -21319,13 +21984,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 241 /* JsxAttribute */) { + if (attribute.kind === 242 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 242 /* JsxSpreadAttribute */) { + else if (attribute.kind === 243 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -21345,7 +22010,7 @@ var ts; * Otherwise this may not be very useful. * * In cases where you *are* working on this function, you should understand - * when it is appropriate to use 'getContextualType' and 'getApparentTypeOfContetxualType'. + * when it is appropriate to use 'getContextualType' and 'getApparentTypeOfContextualType'. * * - Use 'getContextualType' when you are simply going to propagate the result to the expression. * - Use 'getApparentTypeOfContextualType' when you're going to need the members of the type. @@ -21363,40 +22028,40 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 214 /* VariableDeclaration */: - case 139 /* Parameter */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 140 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 167 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 177 /* ArrowFunction */: - case 207 /* ReturnStatement */: + case 178 /* ArrowFunction */: + case 208 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 174 /* TypeAssertionExpression */: - case 192 /* AsExpression */: + case 175 /* TypeAssertionExpression */: + case 193 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 248 /* PropertyAssignment */: + case 249 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 193 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 186 /* TemplateExpression */); + case 194 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 187 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return getContextualType(parent); - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: return getContextualType(parent); - case 241 /* JsxAttribute */: - case 242 /* JsxSpreadAttribute */: + case 242 /* JsxAttribute */: + case 243 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -21413,7 +22078,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 176 /* FunctionExpression */ || node.kind === 177 /* ArrowFunction */; + return node.kind === 177 /* FunctionExpression */ || node.kind === 178 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -21427,7 +22092,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 !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getApparentTypeOfContextualType(node); @@ -21490,13 +22155,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 184 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 185 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 248 /* PropertyAssignment */) { + if (parent.kind === 249 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 167 /* ArrayLiteralExpression */) { + if (parent.kind === 168 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -21512,8 +22177,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 166 /* BindingElement */ && !!node.initializer) || - (node.kind === 184 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + return (node.kind === 167 /* BindingElement */ && !!node.initializer) || + (node.kind === 185 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -21522,7 +22187,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 188 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 189 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -21546,7 +22211,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 188 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 189 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -21561,7 +22226,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 165 /* ArrayBindingPattern */ || pattern.kind === 167 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 166 /* ArrayBindingPattern */ || pattern.kind === 168 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -21569,7 +22234,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 190 /* OmittedExpression */) { + if (patternElement.kind !== 191 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -21584,7 +22249,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 137 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 138 /* 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, @@ -21592,7 +22257,7 @@ var ts; return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132 /* NumberLike */); } function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); + return isTypeAny(type) || isTypeOfKind(type, kind); } function isNumericLiteralName(name) { // The intent of numeric names is that @@ -21633,6 +22298,16 @@ var ts; } return links.resolvedType; } + function getObjectLiteralIndexInfo(node, properties, kind) { + var propTypes = []; + for (var i = 0; i < properties.length; i++) { + if (kind === 0 /* String */ || isNumericName(node.properties[i].name)) { + propTypes.push(getTypeOfSymbol(properties[i])); + } + } + var unionType = propTypes.length ? getUnionType(propTypes) : undefinedType; + return createIndexInfo(unionType, /*isReadonly*/ false); + } function checkObjectLiteral(node, contextualMapper) { var inDestructuringPattern = isAssignmentTarget(node); // Grammar checking @@ -21641,24 +22316,26 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 164 /* ObjectBindingPattern */ || contextualType.pattern.kind === 168 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 165 /* ObjectBindingPattern */ || contextualType.pattern.kind === 169 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; + var hasComputedStringProperty = false; + var hasComputedNumberProperty = false; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 248 /* PropertyAssignment */ || - memberDecl.kind === 249 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 249 /* PropertyAssignment */ || + memberDecl.kind === 250 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 248 /* PropertyAssignment */) { + if (memberDecl.kind === 249 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 144 /* MethodDeclaration */) { + else if (memberDecl.kind === 145 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 249 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 250 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -21666,8 +22343,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 248 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 249 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 249 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 250 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -21701,10 +22378,18 @@ 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 === 146 /* GetAccessor */ || memberDecl.kind === 147 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 147 /* GetAccessor */ || memberDecl.kind === 148 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } - if (!ts.hasDynamicName(memberDecl)) { + if (ts.hasDynamicName(memberDecl)) { + if (isNumericName(memberDecl.name)) { + hasComputedNumberProperty = true; + } + else { + hasComputedStringProperty = true; + } + } + else { propertiesTable[member.name] = member; } propertiesArray.push(member); @@ -21723,37 +22408,15 @@ var ts; } } } - var stringIndexType = getIndexType(0 /* String */); - var numberIndexType = getIndexType(1 /* Number */); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0 /* String */) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1 /* Number */) : undefined; + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */) | (patternWithComputedProperties ? 67108864 /* ObjectLiteralPatternWithComputedProperties */ : 0); if (inDestructuringPattern) { result.pattern = node; } return result; - function getIndexType(kind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - var propTypes = []; - for (var i = 0; i < propertiesArray.length; i++) { - var propertyDecl = node.properties[i]; - if (kind === 0 /* String */ || isNumericName(propertyDecl.name)) { - // Do not call getSymbolOfNode(propertyDecl), as that will get the - // original symbol for the node. We actually want to get the symbol - // created by checkObjectLiteral, since that will be appropriately - // contextually typed and resolved. - var type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, type)) { - propTypes.push(type); - } - } - } - var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= result_1.flags; - return result_1; - } - return undefined; - } } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -21763,18 +22426,18 @@ var ts; // Check attributes checkJsxOpeningLikeElement(node.openingElement); // Perform resolution on the closing tag so that rename/go to definition/etc work - getJsxElementTagSymbol(node.closingElement); + getJsxTagSymbol(node.closingElement); // Check children for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: checkJsxExpression(child); break; - case 236 /* JsxElement */: + case 237 /* JsxElement */: checkJsxElement(child); break; - case 237 /* JsxSelfClosingElement */: + case 238 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -21792,7 +22455,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 === 136 /* QualifiedName */) { + if (tagName.kind === 137 /* QualifiedName */) { return false; } else { @@ -21862,70 +22525,49 @@ var ts; } return jsxTypes[name]; } - /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if - /// this is an intrinsic tag. This might be a named - /// property of the IntrinsicElements interface, or its string indexer. - /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class - /// type or factory function. - /// Otherwise, returns unknownSymbol. - function getJsxElementTagSymbol(node) { + function getJsxTagSymbol(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicTagSymbol(node); + } + else { + return checkExpression(node.tagName).symbol; + } + } + /** + * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic + * property (in which case nodeLinks.jsxFlags will be IntrinsicNamedElement) or an intrinsic + * string index signature (in which case nodeLinks.jsxFlags will be IntrinsicIndexedElement). + * May also return unknownSymbol if both of these lookups fail. + */ + function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - links.resolvedSymbol = lookupIntrinsicTag(node); - } - else { - links.resolvedSymbol = lookupClassTag(node); - } - } - return links.resolvedSymbol; - function lookupIntrinsicTag(node) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { // Property case var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); if (intrinsicProp) { links.jsxFlags |= 1 /* IntrinsicNamedElement */; - return intrinsicProp; + return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); if (indexSignatureType) { links.jsxFlags |= 2 /* IntrinsicIndexedElement */; - return intrinsicElementsType.symbol; + return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); - return unknownSymbol; + return links.resolvedSymbol = unknownSymbol; } else { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } - return unknownSymbol; - } - } - function lookupClassTag(node) { - var valueSymbol = resolveJsxTagName(node); - // Look up the value in the current scope - if (valueSymbol && valueSymbol !== unknownSymbol) { - links.jsxFlags |= 4 /* ValueElement */; - if (valueSymbol.flags & 8388608 /* Alias */) { - markAliasSymbolAsReferenced(valueSymbol); - } - } - return valueSymbol || unknownSymbol; - } - function resolveJsxTagName(node) { - if (node.tagName.kind === 69 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - return sym.exportSymbol || sym; - } - else { - return checkQualifiedName(node.tagName).symbol; + return links.resolvedSymbol = unknownSymbol; } } + return links.resolvedSymbol; } /** * Given a JSX element that is a class element, finds the Element Instance Type. If the @@ -21933,15 +22575,7 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node) { - // 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 /* ValueElement */), "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 - return anyType; - } - var valueType = getTypeOfSymbol(classSymbol); + var valueType = checkExpression(node.tagName); if (isTypeAny(valueType)) { // Short-circuit if the class tag is using an element type 'any' return anyType; @@ -21960,10 +22594,10 @@ var ts; return getUnionType(signatures.map(getReturnTypeOfSignature)); } /// e.g. "props" for React.d.ts, - /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), /// or '' if it has 0 properties (which means every - /// non-instrinsic elements' attributes type is the element instance type) + /// non-intrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); @@ -21971,7 +22605,7 @@ var ts; var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); // JSX.ElementAttributesProperty [type] var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - // The properites of JSX.ElementAttributesProperty + // The properties of JSX.ElementAttributesProperty var attribProperties = attribPropType && getPropertiesOfType(attribPropType); if (attribProperties) { // Element Attributes has zero properties, so the element attributes type will be the class instance type @@ -21998,15 +22632,23 @@ var ts; function getJsxElementAttributesType(node) { var links = getNodeLinks(node); if (!links.resolvedJsxType) { - var sym = getJsxElementTagSymbol(node); - if (links.jsxFlags & 4 /* ValueElement */) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; + } + } + else { // Get the element instance type (the result of newing or invoking this tag) var elemInstanceType = getJsxElementInstanceType(node); var elemClassType = getJsxGlobalElementClassType(); if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { // Is this is a stateless function component? See if its single signature's return type is // assignable to the JSX Element Type - var elemType = getTypeOfSymbol(sym); + var elemType = checkExpression(node.tagName); var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */); var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); @@ -22074,16 +22716,7 @@ var ts; } } } - else if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxType = getTypeOfSymbol(sym); - } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { - return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0 /* String */); - } - else { - // Resolution failed, so we don't know - return links.resolvedJsxType = anyType; - } + return links.resolvedJsxType = unknownType; } return links.resolvedJsxType; } @@ -22137,11 +22770,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 === 241 /* JsxAttribute */) { + if (node.attributes[i].kind === 242 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 242 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 243 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -22171,10 +22804,10 @@ 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 : 142 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 143 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 8 /* Public */ | 64 /* Static */ : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; } /** * Check whether the requested property access is valid. @@ -22186,9 +22819,9 @@ var ts; */ function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); if (left.kind === 95 /* SuperKeyword */) { - var errorNode = node.kind === 169 /* PropertyAccessExpression */ ? + var errorNode = node.kind === 170 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -22198,7 +22831,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 144 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 145 /* 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); @@ -22214,7 +22847,7 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & (16 /* Private */ | 32 /* Protected */))) { + if (!(flags & (8 /* Private */ | 16 /* Protected */))) { return true; } // Property is known to be private or protected at this point @@ -22222,7 +22855,7 @@ var ts; var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; // Private property is accessible if declaring and enclosing class are the same - if (flags & 16 /* Private */) { + if (flags & 8 /* Private */) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -22240,7 +22873,7 @@ var ts; return false; } // No further restrictions for static properties - if (flags & 64 /* Static */) { + if (flags & 32 /* Static */) { return true; } // An instance property must be accessed through an instance of the enclosing class @@ -22285,7 +22918,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 169 /* PropertyAccessExpression */ + var left = node.kind === 170 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -22302,7 +22935,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 215 /* VariableDeclarationList */) { + if (initializer.kind === 216 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -22331,7 +22964,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 203 /* ForInStatement */ && + if (node.kind === 204 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -22348,7 +22981,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 172 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 173 /* 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); @@ -22398,15 +23031,17 @@ var ts; if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { - var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); - if (numberIndexType) { - return numberIndexType; + var numberIndexInfo = getIndexInfoOfType(objectType, 1 /* Number */); + if (numberIndexInfo) { + getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; + return numberIndexInfo.type; } } // Try to use string indexing. - var stringIndexType = getIndexTypeOfType(objectType, 0 /* String */); - if (stringIndexType) { - return stringIndexType; + var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); + if (stringIndexInfo) { + getNodeLinks(node).resolvedIndexInfo = stringIndexInfo; + return stringIndexInfo.type; } // Fall back to any. if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { @@ -22431,7 +23066,7 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 170 /* ElementAccessExpression */ || indexArgumentExpression.kind === 169 /* PropertyAccessExpression */) { + if (indexArgumentExpression.kind === 171 /* ElementAccessExpression */ || indexArgumentExpression.kind === 170 /* PropertyAccessExpression */) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -22486,10 +23121,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 173 /* TaggedTemplateExpression */) { + if (node.kind === 174 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 140 /* Decorator */) { + else if (node.kind !== 141 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -22519,13 +23154,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_5 = signature.declaration && signature.declaration.parent; + var parent_6 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_5 === lastParent) { + if (lastParent && parent_6 === lastParent) { index++; } else { - lastParent = parent_5; + lastParent = parent_6; index = cutoffIndex; } } @@ -22533,7 +23168,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_5; + lastParent = parent_6; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -22555,7 +23190,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 188 /* SpreadElementExpression */) { + if (arg && arg.kind === 189 /* SpreadElementExpression */) { return i; } } @@ -22567,13 +23202,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 === 173 /* TaggedTemplateExpression */) { + if (node.kind === 174 /* 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 === 186 /* TemplateExpression */) { + if (tagExpression.template.kind === 187 /* 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; @@ -22590,7 +23225,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 140 /* Decorator */) { + else if (node.kind === 141 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -22599,7 +23234,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 172 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 173 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -22634,7 +23269,7 @@ var ts; if (type.flags & 80896 /* ObjectType */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { return resolved.callSignatures[0]; } } @@ -22678,7 +23313,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 !== 190 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 191 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -22699,7 +23334,7 @@ var ts; // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. if (excludeArgument) { for (var i = 0; i < argCount; i++) { - // No need to check for omitted args and template expressions, their exlusion value is always undefined + // No need to check for omitted args and template expressions, their exclusion value is always undefined if (excludeArgument[i] === false) { var arg = args[i]; var paramType = getTypeAtPosition(signature, i); @@ -22738,7 +23373,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 !== 190 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 191 /* 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); @@ -22770,16 +23405,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 173 /* TaggedTemplateExpression */) { + if (node.kind === 174 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 186 /* TemplateExpression */) { + if (template.kind === 187 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 140 /* Decorator */) { + else if (node.kind === 141 /* 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. @@ -22804,19 +23439,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 140 /* Decorator */) { + if (node.kind === 141 /* Decorator */) { switch (node.parent.kind) { - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If we are emitting decorators for ES3, we will only pass two arguments. @@ -22826,7 +23461,7 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 139 /* Parameter */: + case 140 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -22850,25 +23485,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 139 /* Parameter */) { + if (node.kind === 140 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 145 /* Constructor */) { + if (node.kind === 146 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 142 /* PropertyDeclaration */ || - node.kind === 144 /* MethodDeclaration */ || - node.kind === 146 /* GetAccessor */ || - node.kind === 147 /* SetAccessor */) { + if (node.kind === 143 /* PropertyDeclaration */ || + node.kind === 145 /* MethodDeclaration */ || + node.kind === 147 /* GetAccessor */ || + node.kind === 148 /* 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 @@ -22895,21 +23530,21 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 139 /* Parameter */) { + if (node.kind === 140 /* Parameter */) { node = node.parent; - if (node.kind === 145 /* Constructor */) { + if (node.kind === 146 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 142 /* PropertyDeclaration */ || - node.kind === 144 /* MethodDeclaration */ || - node.kind === 146 /* GetAccessor */ || - node.kind === 147 /* SetAccessor */) { + if (node.kind === 143 /* PropertyDeclaration */ || + node.kind === 145 /* MethodDeclaration */ || + node.kind === 147 /* GetAccessor */ || + node.kind === 148 /* 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 @@ -22920,9 +23555,9 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getStringLiteralTypeForText(element.name.text); - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { + if (isTypeOfKind(nameType, 16777216 /* ESSymbol */)) { return nameType; } else { @@ -22945,22 +23580,22 @@ var ts; */ function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator - // or its `parameterIndex` for a paramter decorator - if (node.kind === 217 /* ClassDeclaration */) { + // or its `parameterIndex` for a parameter decorator + if (node.kind === 218 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 139 /* Parameter */) { + if (node.kind === 140 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 142 /* PropertyDeclaration */) { + if (node.kind === 143 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144 /* MethodDeclaration */ || - node.kind === 146 /* GetAccessor */ || - node.kind === 147 /* SetAccessor */) { + if (node.kind === 145 /* MethodDeclaration */ || + node.kind === 147 /* GetAccessor */ || + node.kind === 148 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -22992,10 +23627,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 === 140 /* Decorator */) { + if (node.kind === 141 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 174 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -23007,8 +23642,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 === 140 /* Decorator */ || - (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */)) { + if (node.kind === 141 /* Decorator */ || + (argIndex === 0 && node.kind === 174 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -23017,11 +23652,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 140 /* Decorator */) { + if (node.kind === 141 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 174 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -23030,8 +23665,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 173 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 140 /* Decorator */; + var isTaggedTemplate = node.kind === 174 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 141 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -23137,8 +23772,8 @@ var ts; } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - var typeArguments_1 = node.typeArguments; - checkTypeArguments(candidateForTypeArgumentError, typeArguments_1, ts.map(typeArguments_1, getTypeFromTypeNode), /*reportErrors*/ true, headMessage); + var typeArguments_2 = node.typeArguments; + checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNode), /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -23250,8 +23885,10 @@ var ts; // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); - return resolveCall(node, baseConstructors, candidatesOutArray); + if (baseTypeNode) { + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); + } } return resolveUntypedCall(node); } @@ -23275,7 +23912,7 @@ var ts; // We exclude union types because we may have a union of function types that happen to have // no common signatures. if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { - // The unknownType indicates that an error already occured (and was reported). No + // The unknownType indicates that an error already occurred (and was reported). No // need to report another error in this case. if (funcType !== unknownType && node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -23338,6 +23975,9 @@ var ts; // that the user will not add any. var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); if (constructSignatures.length) { + if (!isConstructorAccessible(node, constructSignatures[0])) { + return resolveErrorCall(node); + } return resolveCall(node, constructSignatures, candidatesOutArray); } // If expressionType's apparent type is an object type with no construct signatures but @@ -23355,6 +23995,30 @@ var ts; error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); return resolveErrorCall(node); } + function isConstructorAccessible(node, signature) { + if (!signature || !signature.declaration) { + return true; + } + var declaration = signature.declaration; + var flags = declaration.flags; + // Public constructor is accessible. + if (!(flags & (8 /* Private */ | 16 /* Protected */))) { + return true; + } + var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); + var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol); + // A private or protected constructor can only be instantiated within it's own class + if (!isNodeWithinClass(node, declaringClassDeclaration)) { + if (flags & 8 /* Private */) { + error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); + } + if (flags & 16 /* Protected */) { + error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); + } + return false; + } + return true; + } function resolveTaggedTemplateExpression(node, candidatesOutArray) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); @@ -23377,16 +24041,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 139 /* Parameter */: + case 140 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -23405,7 +24069,7 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorInfo; + var errorInfo = void 0; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); @@ -23423,16 +24087,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 171 /* CallExpression */) { + if (node.kind === 172 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 172 /* NewExpression */) { + else if (node.kind === 173 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 173 /* TaggedTemplateExpression */) { + else if (node.kind === 174 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 140 /* Decorator */) { + else if (node.kind === 141 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -23460,12 +24124,13 @@ var ts; if (node.expression.kind === 95 /* SuperKeyword */) { return voidType; } - if (node.kind === 172 /* NewExpression */) { + if (node.kind === 173 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 145 /* Constructor */ && - declaration.kind !== 149 /* ConstructSignature */ && - declaration.kind !== 154 /* ConstructorType */) { + declaration.kind !== 146 /* Constructor */ && + declaration.kind !== 150 /* ConstructSignature */ && + declaration.kind !== 155 /* ConstructorType */ && + !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations // in a JS file @@ -23480,7 +24145,7 @@ var ts; } } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -23494,8 +24159,8 @@ var ts; if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); // Permit 'number[] | "foo"' to be asserted to 'string'. - var bothAreStringLike = someConstituentTypeHasKind(targetType, 258 /* StringLike */) && - someConstituentTypeHasKind(widenedType, 258 /* StringLike */); + var bothAreStringLike = maybeTypeOfKind(targetType, 258 /* StringLike */) && + maybeTypeOfKind(widenedType, 258 /* StringLike */); if (!bothAreStringLike && !(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } @@ -23526,7 +24191,7 @@ var ts; if (ts.isBindingPattern(node.name)) { for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 190 /* OmittedExpression */) { + if (element.kind !== 191 /* OmittedExpression */) { if (element.name.kind === 69 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } @@ -23574,6 +24239,13 @@ var ts; inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } + function getReturnTypeFromJSDocComment(func) { + var returnTag = ts.getJSDocReturnTag(func); + if (returnTag && returnTag.typeExpression) { + return getTypeFromTypeNode(returnTag.typeExpression.type); + } + return undefined; + } function createPromiseType(promisedType) { // creates a `Promise` type where `T` is the promisedType argument var globalPromiseType = getGlobalPromiseType(); @@ -23591,7 +24263,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 195 /* Block */) { + if (func.body.kind !== 196 /* 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 @@ -23602,7 +24274,7 @@ var ts; } } else { - var types; + var types = void 0; var funcIsGenerator = !!func.asteriskToken; if (funcIsGenerator) { types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); @@ -23641,7 +24313,8 @@ var ts; } else { error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; + // Defer to unioning the return types so we get a) downstream errors earlier and b) better Salsa experience + return getUnionType(types); } } if (funcIsGenerator) { @@ -23704,11 +24377,13 @@ var ts; }); return aggregatedTypes; } - /* - *TypeScript Specification 1.0 (6.3) - July 2014 - * An explicitly typed function whose return type isn't the Void or the Any type - * must have at least one return statement somewhere in its body. - * An exception to this rule is if the function implementation consists of a single 'throw' statement. + /** + * TypeScript Specification 1.0 (6.3) - July 2014 + * An explicitly typed function whose return type isn't the Void type, + * the Any type, or a union type containing the Void or Any type as a constituent + * must have at least one return statement somewhere in its body. + * An exception to this rule is if the function implementation consists of a single 'throw' statement. + * * @param returnType - return type of the function, can be undefined if return type is not explicitly specified */ function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { @@ -23716,15 +24391,15 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType === voidType || isTypeAny(returnType)) { + if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 16 /* Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 195 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 196 /* Block */ || !(func.flags & 32768 /* HasImplicitReturn */)) { return; } - var hasExplicitReturn = func.flags & 1048576 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 65536 /* HasExplicitReturn */; if (returnType && !hasExplicitReturn) { // minimal check: function has syntactic return type annotation and no explicit return statements in the body // this function does not conform to the specification. @@ -23747,10 +24422,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 176 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 177 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -23790,14 +24465,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 144 /* MethodDeclaration */ && node.kind !== 143 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 145 /* MethodDeclaration */ && node.kind !== 144 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -23813,7 +24488,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 195 /* Block */) { + if (node.body.kind === 196 /* Block */) { checkSourceElement(node.body); } else { @@ -23842,75 +24517,74 @@ var ts; } return true; } - function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { - function findSymbol(n) { - var symbol = getNodeLinks(n).resolvedSymbol; - // Because we got the symbol from the resolvedSymbol property, it might be of kind - // SymbolFlags.ExportValue. In this case it is necessary to get the actual export - // symbol, which will have the correct flags set on it. - return symbol && getExportSymbolOfValueSymbolIfExported(symbol); + function isReadonlySymbol(symbol) { + // The following symbols are considered read-only: + // Properties with a 'readonly' modifier + // Variables declared with 'const' + // Get accessors without matching set accessors + // Enum members + return symbol.flags & 4 /* Property */ && (getDeclarationFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || + symbol.flags & 3 /* Variable */ && (getDeclarationFlagsFromSymbol(symbol) & 2048 /* Const */) !== 0 || + symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || + (symbol.flags & 8 /* EnumMember */) !== 0; + } + function isReferenceToReadonlyEntity(expr, symbol) { + if (isReadonlySymbol(symbol)) { + // Allow assignments to readonly properties within constructors of the same class declaration. + if (symbol.flags & 4 /* Property */ && + (expr.kind === 170 /* PropertyAccessExpression */ || expr.kind === 171 /* ElementAccessExpression */) && + expr.expression.kind === 97 /* ThisKeyword */) { + var func = ts.getContainingFunction(expr); + return !(func && func.kind === 146 /* Constructor */ && func.parent === symbol.valueDeclaration.parent); + } + return true; } - function isReferenceOrErrorExpression(n) { - // TypeScript 1.0 spec (April 2014): - // Expressions are classified as values or references. - // References are the subset of expressions that are permitted as the target of an assignment. - // Specifically, references are combinations of identifiers(section 4.3), parentheses(section 4.7), - // and property accesses(section 4.10). - // All other expression constructs described in this chapter are classified as values. - switch (n.kind) { - case 69 /* 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; + return false; + } + function isReferenceThroughNamespaceImport(expr) { + if (expr.kind === 170 /* PropertyAccessExpression */ || expr.kind === 171 /* ElementAccessExpression */) { + var node = skipParenthesizedNodes(expr.expression); + if (node.kind === 69 /* Identifier */) { + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol.flags & 8388608 /* Alias */) { + var declaration = getDeclarationOfAliasSymbol(symbol); + return declaration && declaration.kind === 228 /* NamespaceImport */; } - case 169 /* PropertyAccessExpression */: { - var symbol = findSymbol(n); - // TypeScript 1.0 spec (April 2014): 4.10 - // A property access expression is always classified as a reference. - // NOTE (not in spec): assignment to enum members should not be allowed - return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - } - case 170 /* ElementAccessExpression */: - // old compiler doesn't check indexed access - return true; - case 175 /* ParenthesizedExpression */: - return isReferenceOrErrorExpression(n.expression); - default: - return false; } } - function isConstVariableReference(n) { - switch (n.kind) { - case 69 /* Identifier */: - case 169 /* PropertyAccessExpression */: { - var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384 /* Const */) !== 0; - } - case 170 /* ElementAccessExpression */: { - var index = n.argumentExpression; - var symbol = findSymbol(n.expression); - 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) & 16384 /* Const */) !== 0; - } + return false; + } + function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { + // References are combinations of identifiers, parentheses, and property accesses. + var node = skipParenthesizedNodes(expr); + if (node.kind !== 69 /* Identifier */ && node.kind !== 170 /* PropertyAccessExpression */ && node.kind !== 171 /* ElementAccessExpression */) { + error(expr, invalidReferenceMessage); + return false; + } + // Because we get the symbol from the resolvedSymbol property, it might be of kind + // SymbolFlags.ExportValue. In this case it is necessary to get the actual export + // symbol, which will have the correct flags set on it. + var links = getNodeLinks(node); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol) { + if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { + // Only variables (and not functions, classes, namespaces, enum objects, or enum members) + // are considered references when referenced using a simple identifier. + if (node.kind === 69 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { + error(expr, invalidReferenceMessage); return false; } - case 175 /* ParenthesizedExpression */: - return isConstVariableReference(n.expression); - default: + if (isReferenceToReadonlyEntity(node, symbol) || isReferenceThroughNamespaceImport(node)) { + error(expr, constantVariableMessage); return false; + } } } - if (!isReferenceOrErrorExpression(n)) { - error(n, invalidReferenceMessage); - return false; - } - if (isConstVariableReference(n)) { - error(n, constantVariableMessage); - return false; + else if (node.kind === 171 /* ElementAccessExpression */) { + if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { + error(expr, constantVariableMessage); + return false; + } } return true; } @@ -23929,7 +24603,7 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.parserContextFlags & 8 /* Await */)) { + if (!(node.flags & 33554432 /* AwaitContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -23945,7 +24619,7 @@ var ts; case 35 /* PlusToken */: case 36 /* MinusToken */: case 50 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { + if (maybeTypeOfKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; @@ -23956,7 +24630,7 @@ var ts; 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 - 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } @@ -23967,43 +24641,53 @@ var ts; 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 - 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } - // Just like isTypeOfKind below, except that it returns true if *any* constituent - // has this kind. - function someConstituentTypeHasKind(type, kind) { + // Return true if type might be of the given kind. A union or intersection type might be of a given + // kind if at least one constituent type is of the given kind. + function maybeTypeOfKind(type, kind) { if (type.flags & kind) { return true; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var current = types_10[_i]; - if (current.flags & kind) { + var t = types_10[_i]; + if (maybeTypeOfKind(t, kind)) { return true; } } - return false; } return false; } - // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. - function allConstituentTypesHaveKind(type, kind) { + // Return true if type is of the given kind. A union type is of a given kind if all constituent types + // are of the given kind. An intersection type is of a given kind if at least one constituent type is + // of the given kind. + function isTypeOfKind(type, kind) { if (type.flags & kind) { return true; } - if (type.flags & 49152 /* UnionOrIntersection */) { + if (type.flags & 16384 /* Union */) { var types = type.types; for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var current = types_11[_i]; - if (!(current.flags & kind)) { + var t = types_11[_i]; + if (!isTypeOfKind(t, kind)) { return false; } } return true; } + if (type.flags & 32768 /* Intersection */) { + var types = type.types; + for (var _a = 0, types_12 = types; _a < types_12.length; _a++) { + var t = types_12[_a]; + if (isTypeOfKind(t, kind)) { + return true; + } + } + } return false; } function isConstEnumObjectType(type) { @@ -24018,7 +24702,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, 16777726 /* Primitive */)) { + if (isTypeOfKind(leftType, 16777726 /* Primitive */)) { error(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 @@ -24044,22 +24728,22 @@ var ts; var properties = node.properties; for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var p = properties_3[_i]; - if (p.kind === 248 /* PropertyAssignment */ || p.kind === 249 /* ShorthandPropertyAssignment */) { - var name_13 = p.name; - if (name_13.kind === 137 /* ComputedPropertyName */) { - checkComputedPropertyName(name_13); + if (p.kind === 249 /* PropertyAssignment */ || p.kind === 250 /* ShorthandPropertyAssignment */) { + var name_12 = p.name; + if (name_12.kind === 138 /* ComputedPropertyName */) { + checkComputedPropertyName(name_12); } - if (isComputedNonLiteralName(name_13)) { + if (isComputedNonLiteralName(name_12)) { continue; } - var text = getTextOfPropertyName(name_13); + var text = getTextOfPropertyName(name_12); var type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, text) || isNumericLiteralName(text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - if (p.kind === 249 /* ShorthandPropertyAssignment */) { + if (p.kind === 250 /* ShorthandPropertyAssignment */) { checkDestructuringAssignment(p, type); } else { @@ -24068,7 +24752,7 @@ var ts; } } else { - error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); + error(name_12, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_12)); } } else { @@ -24085,8 +24769,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 190 /* OmittedExpression */) { - if (e.kind !== 188 /* SpreadElementExpression */) { + if (e.kind !== 191 /* OmittedExpression */) { + if (e.kind !== 189 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -24111,7 +24795,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 184 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + if (restExpression.kind === 185 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -24125,7 +24809,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 249 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 250 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); @@ -24135,21 +24819,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 184 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + if (target.kind === 185 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 168 /* ObjectLiteralExpression */) { + if (target.kind === 169 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 167 /* ArrayLiteralExpression */) { + if (target.kind === 168 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) { checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; @@ -24159,7 +24843,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 168 /* ObjectLiteralExpression */ || left.kind === 167 /* ArrayLiteralExpression */)) { + if (operator === 56 /* EqualsToken */ && (left.kind === 169 /* ObjectLiteralExpression */ || left.kind === 168 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -24197,7 +24881,7 @@ var ts; leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) rightType = leftType; - var suggestedOperator; + var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion if ((leftType.flags & 8 /* Boolean */) && @@ -24224,14 +24908,14 @@ var ts; leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) rightType = leftType; - var resultType; - if (allConstituentTypesHaveKind(leftType, 132 /* NumberLike */) && allConstituentTypesHaveKind(rightType, 132 /* NumberLike */)) { + var resultType = void 0; + if (isTypeOfKind(leftType, 132 /* NumberLike */) && isTypeOfKind(rightType, 132 /* NumberLike */)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } else { - if (allConstituentTypesHaveKind(leftType, 258 /* StringLike */) || allConstituentTypesHaveKind(rightType, 258 /* StringLike */)) { + if (isTypeOfKind(leftType, 258 /* StringLike */) || isTypeOfKind(rightType, 258 /* StringLike */)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -24266,7 +24950,7 @@ var ts; case 32 /* EqualsEqualsEqualsToken */: case 33 /* ExclamationEqualsEqualsToken */: // Permit 'number[] | "foo"' to be asserted to 'string'. - if (someConstituentTypeHasKind(leftType, 258 /* StringLike */) && someConstituentTypeHasKind(rightType, 258 /* StringLike */)) { + if (maybeTypeOfKind(leftType, 258 /* StringLike */) && maybeTypeOfKind(rightType, 258 /* StringLike */)) { return booleanType; } if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { @@ -24289,8 +24973,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : - someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 16777216 /* ESSymbol */) ? left : + maybeTypeOfKind(rightType, 16777216 /* ESSymbol */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -24321,7 +25005,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported @@ -24351,7 +25035,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.parserContextFlags & 2 /* Yield */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8388608 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -24364,7 +25048,7 @@ var ts; // we are in a yield context. if (func && func.asteriskToken) { var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); - var expressionElementType; + var expressionElementType = void 0; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); @@ -24428,7 +25112,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 === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -24439,7 +25123,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 === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -24469,7 +25153,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 136 /* QualifiedName */) { + if (node.kind === 137 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -24481,9 +25165,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 170 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 171 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 137 /* 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); } @@ -24510,7 +25194,7 @@ var ts; return booleanType; case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: return checkTemplateExpression(node); case 9 /* StringLiteral */: return checkStringLiteralExpression(node); @@ -24518,58 +25202,58 @@ var ts; return stringType; case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 169 /* PropertyAccessExpression */: + case 170 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 170 /* ElementAccessExpression */: + case 171 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return checkCallExpression(node); - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: return checkClassExpression(node); - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 179 /* TypeOfExpression */: + case 180 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 174 /* TypeAssertionExpression */: - case 192 /* AsExpression */: + case 175 /* TypeAssertionExpression */: + case 193 /* AsExpression */: return checkAssertion(node); - case 178 /* DeleteExpression */: + case 179 /* DeleteExpression */: return checkDeleteExpression(node); - case 180 /* VoidExpression */: + case 181 /* VoidExpression */: return checkVoidExpression(node); - case 181 /* AwaitExpression */: + case 182 /* AwaitExpression */: return checkAwaitExpression(node); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 183 /* PostfixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 188 /* SpreadElementExpression */: + case 189 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 190 /* OmittedExpression */: + case 191 /* OmittedExpression */: return undefinedType; - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: return checkYieldExpression(node); - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: return checkJsxExpression(node); - case 236 /* JsxElement */: + case 237 /* JsxElement */: return checkJsxElement(node); - case 237 /* JsxSelfClosingElement */: + case 238 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 238 /* JsxOpeningElement */: + case 239 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -24595,9 +25279,9 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 56 /* AccessibilityModifier */) { + if (node.flags & 28 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 145 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 146 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -24614,9 +25298,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 144 /* MethodDeclaration */ || - node.kind === 216 /* FunctionDeclaration */ || - node.kind === 176 /* FunctionExpression */; + return node.kind === 145 /* MethodDeclaration */ || + node.kind === 217 /* FunctionDeclaration */ || + node.kind === 177 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -24633,18 +25317,19 @@ var ts; function checkTypePredicate(node) { var parent = getTypePredicateParent(node); if (!parent) { + // The parent must not be valid. + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; } - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(parent)); - if (!returnType || !(returnType.flags & 134217728 /* PredicateType */)) { + var typePredicate = getSignatureFromDeclaration(parent).typePredicate; + if (!typePredicate) { return; } var parameterName = node.parameterName; - if (parameterName.kind === 162 /* ThisType */) { + if (ts.isThisTypePredicate(typePredicate)) { getTypeFromThisTypeNode(parameterName); } else { - var typePredicate = returnType.predicate; if (typePredicate.parameterIndex >= 0) { if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); @@ -24656,10 +25341,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_14 = _a[_i].name; - if ((name_14.kind === 164 /* ObjectBindingPattern */ || - name_14.kind === 165 /* ArrayBindingPattern */) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, parameterName, typePredicate.parameterName)) { + var name_13 = _a[_i].name; + if (ts.isBindingPattern(name_13) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_13, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -24672,30 +25356,30 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 177 /* ArrowFunction */: - case 148 /* CallSignature */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 153 /* FunctionType */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - var parent_6 = node.parent; - if (node === parent_6.type) { - return parent_6; + case 178 /* ArrowFunction */: + case 149 /* CallSignature */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 154 /* FunctionType */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + var parent_7 = node.parent; + if (node === parent_7.type) { + return parent_7; } } } function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var name_15 = _a[_i].name; - if (name_15.kind === 69 /* Identifier */ && - name_15.text === predicateVariableName) { + var name_14 = _a[_i].name; + if (name_14.kind === 69 /* Identifier */ && + name_14.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_15.kind === 165 /* ArrayBindingPattern */ || - name_15.kind === 164 /* ObjectBindingPattern */) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_15, predicateVariableNode, predicateVariableName)) { + else if (name_14.kind === 166 /* ArrayBindingPattern */ || + name_14.kind === 165 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, predicateVariableNode, predicateVariableName)) { return true; } } @@ -24703,25 +25387,27 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 150 /* IndexSignature */) { + if (node.kind === 151 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 153 /* FunctionType */ || node.kind === 216 /* FunctionDeclaration */ || node.kind === 154 /* ConstructorType */ || - node.kind === 148 /* CallSignature */ || node.kind === 145 /* Constructor */ || - node.kind === 149 /* ConstructSignature */) { + else if (node.kind === 154 /* FunctionType */ || node.kind === 217 /* FunctionDeclaration */ || node.kind === 155 /* ConstructorType */ || + node.kind === 149 /* CallSignature */ || node.kind === 146 /* Constructor */ || + node.kind === 150 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); - checkSourceElement(node.type); + if (node.type) { + checkSourceElement(node.type); + } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 148 /* CallSignature */: + case 149 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -24744,12 +25430,14 @@ var ts; checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } + else if (ts.isAsyncFunctionLike(node)) { + checkAsyncFunctionReturnType(node); + } } } - checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 218 /* InterfaceDeclaration */) { + if (node.kind === 219 /* 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 @@ -24769,7 +25457,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 130 /* StringKeyword */: + case 131 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -24777,7 +25465,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 128 /* NumberKeyword */: + case 129 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -24809,7 +25497,7 @@ var ts; function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. checkSignatureDeclaration(node); - // Grammar check for checking only related to constructoDeclaration + // Grammar check for checking only related to constructorDeclaration checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); var symbol = getSymbolOfNode(node); @@ -24825,14 +25513,11 @@ var ts; if (!produceDiagnostics) { return; } - function isSuperCallExpression(n) { - return n.kind === 171 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; - } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { - if (isSuperCallExpression(n)) { + if (ts.isSuperCallExpression(n)) { return true; } else if (ts.isFunctionLike(n)) { @@ -24847,13 +25532,13 @@ var ts; if (n.kind === 97 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 176 /* FunctionExpression */ && n.kind !== 216 /* FunctionDeclaration */) { + else if (n.kind !== 177 /* FunctionExpression */ && n.kind !== 217 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 142 /* PropertyDeclaration */ && - !(n.flags & 64 /* Static */) && + return n.kind === 143 /* PropertyDeclaration */ && + !(n.flags & 32 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 @@ -24861,12 +25546,11 @@ var ts; // constructors of derived classes must contain at least one super call somewhere in their function body. 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 classExtendsNull = classDeclarationExtendsNull(containingClassDecl); + var superCall = getSuperCallInConstructor(node); + if (superCall) { + if (classExtendsNull) { + error(superCall, 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: @@ -24874,15 +25558,15 @@ var ts; // - 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 & (8 /* Public */ | 16 /* Private */ | 32 /* Protected */); }); + ts.forEach(node.parameters, function (p) { return p.flags & (4 /* Public */ | 8 /* Private */ | 16 /* 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; - var superCallStatement; + var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 198 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + if (statement.kind === 199 /* ExpressionStatement */ && ts.isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -24893,13 +25577,9 @@ var ts; 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(superCallStatement.expression); - } } } - else if (baseConstructorType !== nullType) { + else if (!classExtendsNull) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -24910,9 +25590,9 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 146 /* GetAccessor */) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288 /* HasImplicitReturn */)) { - if (node.flags & 1048576 /* HasExplicitReturn */) { + if (node.kind === 147 /* GetAccessor */) { + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 32768 /* HasImplicitReturn */)) { + if (node.flags & 65536 /* HasExplicitReturn */) { if (compilerOptions.noImplicitReturns) { error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -24925,18 +25605,21 @@ 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 === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 146 /* GetAccessor */ ? 147 /* SetAccessor */ : 146 /* GetAccessor */; + var otherKind = node.kind === 147 /* GetAccessor */ ? 148 /* SetAccessor */ : 147 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 56 /* AccessibilityModifier */) !== (otherAccessor.flags & 56 /* AccessibilityModifier */))) { + if (((node.flags & 28 /* AccessibilityModifier */) !== (otherAccessor.flags & 28 /* AccessibilityModifier */))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } + if (((node.flags & 128 /* Abstract */) !== (otherAccessor.flags & 128 /* Abstract */))) { + error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + } var currentAccessorType = getAnnotatedAccessorType(node); var otherAccessorType = getAnnotatedAccessorType(otherAccessor); // TypeScript 1.0 spec (April 2014): 4.5 @@ -24950,7 +25633,7 @@ var ts; } getTypeOfAccessors(getSymbolOfNode(node)); } - if (node.parent.kind !== 168 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 169 /* ObjectLiteralExpression */) { checkSourceElement(node.body); } else { @@ -25019,59 +25702,21 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 16 /* Private */) && ts.isInAmbientContext(node); - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { - if (!produceDiagnostics) { - return; - } - var signature = getSignatureFromDeclaration(signatureDeclarationNode); - if (!signature.hasStringLiterals) { - return; - } - // TypeScript 1.0 spec (April 2014): 3.7.2.2 - // Specialized signatures are not permitted in conjunction with a function body - if (ts.nodeIsPresent(signatureDeclarationNode.body)) { - error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); - return; - } - // TypeScript 1.0 spec (April 2014): 3.7.2.4 - // Every specialized call or construct signature in an object type must be assignable - // to at least one non-specialized call or construct signature in the same object type - 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 === 218 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 148 /* CallSignature */ || signatureDeclarationNode.kind === 149 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 148 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; - var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - var containingType = getDeclaredTypeOfSymbol(containingSymbol); - signaturesToCheck = getSignaturesOfType(containingType, signatureKind); - } - else { - signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); - } - for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { - var otherSignature = signaturesToCheck_1[_i]; - if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature, /*ignoreReturnTypes*/ false)) { - return; - } - } - error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); + return (node.flags & 8 /* Private */) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 218 /* InterfaceDeclaration */ && - n.parent.kind !== 217 /* ClassDeclaration */ && - n.parent.kind !== 189 /* ClassExpression */ && + if (n.parent.kind !== 219 /* InterfaceDeclaration */ && + n.parent.kind !== 218 /* ClassDeclaration */ && + n.parent.kind !== 190 /* ClassExpression */ && ts.isInAmbientContext(n)) { - if (!(flags & 4 /* Ambient */)) { + if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported - flags |= 2 /* Export */; + flags |= 1 /* Export */; } - flags |= 4 /* Ambient */; + flags |= 2 /* Ambient */; } return flags & flagsToCheck; } @@ -25093,36 +25738,36 @@ var ts; // deviations, we XOR someOverloadFlags with allOverloadFlags var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; if (someButNotAllOverloadFlags !== 0) { - var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); + var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { - var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 2 /* Export */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); + var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; + if (deviation & 1 /* Export */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 4 /* Ambient */) { + else if (deviation & 2 /* Ambient */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (16 /* Private */ | 32 /* Protected */)) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); + else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + error(o.name || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } else if (deviation & 128 /* Abstract */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); } } function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { if (someHaveQuestionToken !== allHaveQuestionToken) { - var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); ts.forEach(overloads, function (o) { - var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1; if (deviation) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); } }); } } - var flagsToCheck = 2 /* Export */ | 4 /* Ambient */ | 16 /* Private */ | 32 /* Protected */ | 128 /* Abstract */; + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -25146,21 +25791,21 @@ var ts; seen = c === node; } }); - // We may be here because of some extra junk between overloads that could not be parsed into a valid node. + // We may be here because of some extra nodes between overloads that could not be parsed into a valid node. // In this case the subsequent node is not really consecutive (.pos !== node.end), and we must ignore it here. if (subsequentNode && subsequentNode.pos === node.end) { if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) && - (node.flags & 64 /* Static */) !== (subsequentNode.flags & 64 /* Static */); + var reportError = (node.kind === 145 /* MethodDeclaration */ || node.kind === 144 /* MethodSignature */) && + (node.flags & 32 /* Static */) !== (subsequentNode.flags & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members // 2. something with the same name was defined before the set of overloads that prevents them from merging // here we'll report error only for the first case since for second we should already report error in binder if (reportError) { - var diagnostic = node.flags & 64 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = node.flags & 32 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -25195,7 +25840,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 218 /* InterfaceDeclaration */ || node.parent.kind === 156 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 219 /* InterfaceDeclaration */ || node.parent.kind === 157 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -25206,7 +25851,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 === 216 /* FunctionDeclaration */ || node.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */ || node.kind === 145 /* Constructor */) { + if (node.kind === 217 /* FunctionDeclaration */ || node.kind === 145 /* MethodDeclaration */ || node.kind === 144 /* MethodSignature */ || node.kind === 146 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -25258,29 +25903,11 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - // If the implementation signature has string literals, we will have reported an error in - // checkSpecializedSignatureDeclaration - if (!bodySignature.hasStringLiterals) { - // TypeScript 1.0 spec (April 2014): 6.1 - // If a function declaration includes overloads, the overloads determine the call - // signatures of the type given to the function object - // and the function implementation signature must be assignable to that type - // - // TypeScript 1.0 spec (April 2014): 3.8.4 - // Note that specialized call and construct signatures (section 3.7.2.4) are not significant when determining assignment compatibility - // Consider checking against specialized signatures too. Not doing so creates a type hole: - // - // function g(x: "hi", y: boolean); - // function g(x: string, y: {}); - // function g(x: string, y: string) { } - // - // The implementation is completely unrelated to the specialized signature, yet we do not check this. - for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { - var signature = signatures_3[_a]; - if (!signature.hasStringLiterals && !isImplementationCompatibleWithOverload(bodySignature, signature)) { - error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); - break; - } + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; + if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { + error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); + break; } } } @@ -25313,8 +25940,8 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 2 /* Export */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { if (effectiveDeclarationFlags & 512 /* Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } @@ -25326,7 +25953,7 @@ var ts; nonExportedDeclarationSpaces |= declarationSpaces; } } - // Spaces for anyting not declared a 'default export'. + // Spaces for anything not declared a 'default export'. var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; @@ -25335,7 +25962,7 @@ var ts; 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. + // Only error on the declarations that contributed 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)); } @@ -25346,20 +25973,20 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 224 /* ImportEqualsDeclaration */: - var result = 0; + case 225 /* ImportEqualsDeclaration */: + var result_1 = 0; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); - return result; + ts.forEach(target.declarations, function (d) { result_1 |= getDeclarationSpaces(d); }); + return result_1; default: return 1048576 /* ExportValue */; } @@ -25516,6 +26143,33 @@ var ts; } } } + /** + * Checks that the return type provided is an instantiation of the global Promise type + * and returns the awaited type of the return type. + * + * @param returnType The return type of a FunctionLikeDeclaration + * @param location The node on which to report the error. + */ + function checkCorrectPromiseType(returnType, location) { + if (returnType === unknownType) { + // The return type already had some other error, so we ignore and return + // the unknown type. + return unknownType; + } + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType === emptyGenericType + || globalPromiseType === getTargetType(returnType)) { + // Either we couldn't resolve the global promise type, which would have already + // reported an error, or we could resolve it and the return type is a valid type + // reference to the global type. In either case, we return the awaited type for + // the return type. + return checkAwaitedType(returnType, location, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + // The promise type was not a valid type reference to the global promise type, so we + // report an error and return the unknown type. + error(location, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + return unknownType; + } /** * Checks the return type of an async function to ensure it is a compatible * Promise implementation. @@ -25530,6 +26184,10 @@ var ts; * callable `then` signature. */ function checkAsyncFunctionReturnType(node) { + if (languageVersion >= 2 /* ES6 */) { + var returnType = getTypeFromTypeNode(node.type); + return checkCorrectPromiseType(returnType, node.type); + } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify @@ -25605,22 +26263,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 139 /* Parameter */: + case 140 /* 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 142 /* PropertyDeclaration */: + case 143 /* 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 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -25633,9 +26291,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 152 /* TypeReference */) { + if (node && node.kind === 153 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 152 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = root.parent.kind === 153 /* 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 @@ -25677,25 +26335,25 @@ var ts; return; } if (!compilerOptions.experimentalDecorators) { - error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } if (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 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 142 /* PropertyDeclaration */: - case 139 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 140 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } @@ -25708,6 +26366,7 @@ var ts; checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function checkFunctionOrMethodDeclaration(node) { @@ -25717,7 +26376,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 === 137 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 138 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -25768,7 +26427,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 195 /* Block */) { + if (node.kind === 196 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -25788,12 +26447,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 142 /* PropertyDeclaration */ || - node.kind === 141 /* PropertySignature */ || - node.kind === 144 /* MethodDeclaration */ || - node.kind === 143 /* MethodSignature */ || - node.kind === 146 /* GetAccessor */ || - node.kind === 147 /* SetAccessor */) { + if (node.kind === 143 /* PropertyDeclaration */ || + node.kind === 142 /* PropertySignature */ || + node.kind === 145 /* MethodDeclaration */ || + node.kind === 144 /* MethodSignature */ || + node.kind === 147 /* GetAccessor */ || + node.kind === 148 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -25802,7 +26461,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 139 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 140 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -25855,16 +26514,31 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 221 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 222 /* 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 === 251 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 252 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } + function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "Promise")) { + return; + } + // Uninstantiated modules shouldnt do this check + if (node.kind === 222 /* 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 === 252 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2097152 /* HasAsyncFunctions */) { + // If the declaration happens to be in external module, report error that Promise is a reserved identifier. + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); + } + } function checkVarDeclaredNamesNotShadowed(node) { // - ScriptBody : StatementList // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList @@ -25889,13 +26563,13 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3072 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // 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 === 214 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 215 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -25904,25 +26578,25 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 215 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 196 /* VariableStatement */ && varDeclList.parent.parent + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 3072 /* BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 216 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 197 /* 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 === 195 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 222 /* ModuleBlock */ || - container.kind === 221 /* ModuleDeclaration */ || - container.kind === 251 /* SourceFile */); + (container.kind === 196 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 223 /* ModuleBlock */ || + container.kind === 222 /* ModuleDeclaration */ || + container.kind === 252 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail // since LHS will be block scoped name instead of function scoped if (!namesShareScope) { - var name_16 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_16, name_16); + 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); } } } @@ -25930,7 +26604,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 139 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 140 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -25941,7 +26615,7 @@ var ts; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 139 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 140 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -25967,15 +26641,15 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 166 /* BindingElement */) { + if (node.kind === 167 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 137 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } } @@ -25984,14 +26658,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 === 139 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 140 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 203 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 204 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -26002,7 +26676,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 203 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 204 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -26018,15 +26692,16 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 142 /* PropertyDeclaration */ && node.kind !== 141 /* PropertySignature */) { + if (node.kind !== 143 /* PropertyDeclaration */ && node.kind !== 142 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 214 /* VariableDeclaration */ || node.kind === 166 /* BindingElement */) { + if (node.kind === 215 /* VariableDeclaration */ || node.kind === 167 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function checkVariableDeclaration(node) { @@ -26044,7 +26719,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 === 168 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 169 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -26065,7 +26740,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 197 /* EmptyStatement */) { + if (node.thenStatement.kind === 198 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -26085,12 +26760,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 216 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -26110,14 +26785,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 === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* 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 === 167 /* ArrayLiteralExpression */ || varExpr.kind === 168 /* ObjectLiteralExpression */) { + if (varExpr.kind === 168 /* ArrayLiteralExpression */ || varExpr.kind === 169 /* 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. @@ -26126,7 +26801,7 @@ var ts; else { var leftType = checkExpression(varExpr); checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, - /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); // 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 @@ -26146,7 +26821,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 === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* 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); @@ -26160,7 +26835,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 === 167 /* ArrayLiteralExpression */ || varExpr.kind === 168 /* ObjectLiteralExpression */) { + if (varExpr.kind === 168 /* ArrayLiteralExpression */ || varExpr.kind === 169 /* 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 */)) { @@ -26168,7 +26843,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); } } var rightType = checkExpression(node.expression); @@ -26339,7 +27014,7 @@ var ts; * This function does the following steps: * 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents. * 2. Take the element types of the array constituents. - * 3. Return the union of the element types, and string if there was a string constitutent. + * 3. Return the union of the element types, and string if there was a string constituent. * * For example: * string -> string @@ -26404,8 +27079,8 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); // TODO: Check that target label is valid } - function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 146 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 147 /* SetAccessor */))); + function isGetAccessorWithAnnotatedSetAccessor(node) { + return !!(node.kind === 147 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 148 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -26428,15 +27103,15 @@ var ts; // for generators. return; } - if (func.kind === 147 /* SetAccessor */) { + if (func.kind === 148 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 145 /* Constructor */) { + else if (func.kind === 146 /* Constructor */) { if (!checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || returnType.flags & 134217728 /* PredicateType */) { + else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -26457,7 +27132,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 8 /* Await */) { + if (node.flags & 33554432 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -26470,10 +27145,10 @@ var ts; var firstDefaultClause; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); - var expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, 258 /* StringLike */); + var expressionTypeIsStringLike = maybeTypeOfKind(expressionType, 258 /* StringLike */); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 245 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 246 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -26485,14 +27160,14 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 244 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 245 /* 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); var expressionTypeIsAssignableToCaseType = // Permit 'number[] | "foo"' to be asserted to 'string'. - (expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, 258 /* StringLike */)) || + (expressionTypeIsStringLike && maybeTypeOfKind(caseType, 258 /* StringLike */)) || isTypeAssignableTo(expressionType, caseType); if (!expressionTypeIsAssignableToCaseType) { // 'expressionType is not assignable to caseType', try the reversed check and report errors if it fails @@ -26510,7 +27185,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 210 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 211 /* 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; @@ -26584,7 +27259,7 @@ var ts; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!(member.flags & 64 /* Static */) && ts.hasDynamicName(member)) { + if (!(member.flags & 32 /* Static */) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); @@ -26615,7 +27290,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 === 137 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 138 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -26649,7 +27324,7 @@ var ts; error(name, message, name.text); } } - // Check each type parameter and check that list has no duplicate type parameter declarations + /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { @@ -26665,6 +27340,24 @@ var ts; } } } + /** Check that type parameter lists are identical across multiple declarations */ + function checkTypeParameterListsIdentical(node, symbol) { + if (symbol.declarations.length === 1) { + return; + } + var firstDecl; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 218 /* ClassDeclaration */ || declaration.kind === 219 /* InterfaceDeclaration */) { + if (!firstDecl) { + firstDecl = declaration; + } + else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + } + } + } + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -26687,6 +27380,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } checkTypeParameters(node.typeParameters); checkExportsOnMergedDeclarations(node); @@ -26694,12 +27388,14 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); + checkTypeParameterListsIdentical(node, symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { - var baseType = baseTypes[0]; + var baseType_1 = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); @@ -26710,7 +27406,7 @@ var ts; } } } - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify @@ -26718,11 +27414,11 @@ var ts; // references (as opposed to checking the structure of the types) because elsewhere we have already checked // that the base type is a class or interface type (and not, for example, an anonymous object type). var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); - if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } - checkKindsOfPropertyMemberOverrides(type, baseType); + checkKindsOfPropertyMemberOverrides(type, baseType_1); } } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); @@ -26752,6 +27448,18 @@ var ts; checkTypeForDuplicateIndexSignatures(node); } } + function checkBaseTypeAccessibility(type, node) { + var signatures = getSignaturesOfType(type, 1 /* Construct */); + if (signatures.length) { + var declaration = signatures[0].declaration; + if (declaration && declaration.flags & 8 /* Private */) { + var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); + if (!isNodeWithinClass(node, typeClassDeclaration)) { + error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, node.expression.text); + } + } + } + } function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags @@ -26786,7 +27494,7 @@ var ts; var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { - // In order to resolve whether the inherited method was overriden in the base class or not, + // In order to resolve whether the inherited method was overridden in the base class or not, // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { @@ -26796,7 +27504,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 189 /* ClassExpression */) { + if (derivedClassDecl.kind === 190 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -26807,11 +27515,11 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 16 /* Private */) || (derivedDeclarationFlags & 16 /* Private */)) { + if ((baseDeclarationFlags & 8 /* Private */) || (derivedDeclarationFlags & 8 /* Private */)) { // either base or derived property is private - not override, skip it continue; } - if ((baseDeclarationFlags & 64 /* Static */) !== (derivedDeclarationFlags & 64 /* Static */)) { + if ((baseDeclarationFlags & 32 /* Static */) !== (derivedDeclarationFlags & 32 /* Static */)) { // value of 'static' is not the same for properties - not override, skip it continue; } @@ -26844,7 +27552,7 @@ var ts; } } function isAccessor(kind) { - return kind === 146 /* GetAccessor */ || kind === 147 /* SetAccessor */; + return kind === 147 /* GetAccessor */ || kind === 148 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -26914,13 +27622,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 218 /* InterfaceDeclaration */); - if (symbol.declarations.length > 1) { - if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); - } - } + checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 219 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -26953,7 +27657,7 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { + if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; // set to undefined when enum member is non-constant @@ -26992,7 +27696,7 @@ var ts; autoValue++; } } - nodeLinks.flags |= 8192 /* EnumValuesComputed */; + nodeLinks.flags |= 16384 /* EnumValuesComputed */; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { // Controls if error should be reported after evaluation of constant value is completed @@ -27024,7 +27728,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -27035,7 +27739,7 @@ var ts; case 50 /* TildeToken */: return ~value_1; } return undefined; - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -27060,15 +27764,15 @@ var ts; return undefined; case 8 /* NumericLiteral */: return +e.text; - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return evalConstant(e.expression); case 69 /* Identifier */: - case 170 /* ElementAccessExpression */: - case 169 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 170 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; - var propertyName; + var propertyName = void 0; if (e.kind === 69 /* 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 @@ -27076,8 +27780,8 @@ var ts; propertyName = e.text; } else { - var expression; - if (e.kind === 170 /* ElementAccessExpression */) { + var expression = void 0; + if (e.kind === 171 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -27095,7 +27799,7 @@ var ts; if (current.kind === 69 /* Identifier */) { break; } - else if (current.kind === 169 /* PropertyAccessExpression */) { + else if (current.kind === 170 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -27140,6 +27844,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumIsConst = ts.isConst(node); @@ -27163,10 +27868,10 @@ var ts; } }); } - var seenEnumMissingInitialInitializer = false; + var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 220 /* EnumDeclaration */) { + if (declaration.kind !== 221 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -27175,11 +27880,11 @@ var ts; } var firstEnumMember = enumDeclaration.members[0]; if (!firstEnumMember.initializer) { - if (seenEnumMissingInitialInitializer) { + if (seenEnumMissingInitialInitializer_1) { error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); } else { - seenEnumMissingInitialInitializer = true; + seenEnumMissingInitialInitializer_1 = true; } } }); @@ -27189,8 +27894,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 217 /* ClassDeclaration */ || - (declaration.kind === 216 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 218 /* ClassDeclaration */ || + (declaration.kind === 217 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -27233,6 +27938,7 @@ var ts; } checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. @@ -27251,7 +27957,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, 217 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 218 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -27260,10 +27966,10 @@ var ts; if (isAmbientExternalModule) { if (ts.isExternalModuleAugmentation(node)) { // body of the augmentation should be checked for consistency only if augmentation was applied to its target (either global scope or module) - // otherwise we'll be swamped in cascading errors. + // otherwise we'll be swamped in cascading errors. // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied - // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). + // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */); if (checkBody) { // body of ambient external module is always a module block @@ -27297,31 +28003,31 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 230 /* ExportAssignment */: - case 231 /* ExportDeclaration */: + case 231 /* ExportAssignment */: + case 232 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: if (node.moduleReference.kind !== 9 /* StringLiteral */) { error(node.name, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); break; } // fallthrough - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 166 /* BindingElement */: - case 214 /* VariableDeclaration */: - var name_17 = node.name; - if (ts.isBindingPattern(name_17)) { - for (var _b = 0, _c = name_17.elements; _b < _c.length; _b++) { + case 167 /* BindingElement */: + case 215 /* VariableDeclaration */: + var name_16 = node.name; + if (ts.isBindingPattern(name_16)) { + for (var _b = 0, _c = name_16.elements; _b < _c.length; _b++) { var el = _c[_b]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); @@ -27329,12 +28035,12 @@ var ts; break; } // fallthrough - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 216 /* FunctionDeclaration */: - case 218 /* InterfaceDeclaration */: - case 221 /* ModuleDeclaration */: - case 219 /* TypeAliasDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 217 /* FunctionDeclaration */: + case 219 /* InterfaceDeclaration */: + case 222 /* ModuleDeclaration */: + case 220 /* TypeAliasDeclaration */: var symbol = getSymbolOfNode(node); if (symbol) { // module augmentations cannot introduce new names on the top level scope of the module @@ -27361,10 +28067,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 136 /* QualifiedName */) { + if (node.kind === 137 /* QualifiedName */) { node = node.left; } - else if (node.kind === 169 /* PropertyAccessExpression */) { + else if (node.kind === 170 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -27380,9 +28086,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 222 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 251 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 231 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 223 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 252 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 232 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -27409,7 +28115,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 === 233 /* ExportSpecifier */ ? + var message = node.kind === 234 /* 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)); @@ -27419,6 +28125,7 @@ var ts; function checkImportBinding(node) { checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); } function checkImportDeclaration(node) { @@ -27426,7 +28133,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -27436,7 +28143,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 228 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -27454,7 +28161,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -27473,7 +28180,7 @@ var ts; } } else { - if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.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_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -27485,7 +28192,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -27493,22 +28200,22 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 222 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 251 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 223 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 252 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } else { // export * from "foo" var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol && moduleSymbol.exports["export="]) { + if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } } } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 251 /* SourceFile */ && node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 221 /* ModuleDeclaration */) { + if (node.parent.kind !== 252 /* SourceFile */ && node.parent.kind !== 223 /* ModuleBlock */ && node.parent.kind !== 222 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -27519,7 +28226,7 @@ var ts; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); } else { @@ -27532,13 +28239,13 @@ 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 === 251 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 221 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 252 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 222 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69 /* Identifier */) { @@ -27549,11 +28256,11 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === 5 /* ES6 */) { + if (modulekind === ts.ModuleKind.ES6) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (modulekind === 4 /* System */) { + else if (modulekind === ts.ModuleKind.System) { // system modules does not support export assignment grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } @@ -27585,12 +28292,21 @@ var ts; continue; } var _a = exports[id], declarations = _a.declarations, flags = _a.flags; - // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (!(flags & (1536 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) && (flags & 524288 /* TypeAlias */ ? declarations.length - 1 : declarations.length) > 1) { - var exportedDeclarations = ts.filter(declarations, isNotOverload); - if (exportedDeclarations.length > 1) { - for (var _i = 0, exportedDeclarations_1 = exportedDeclarations; _i < exportedDeclarations_1.length; _i++) { - var declaration = exportedDeclarations_1[_i]; + // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. + // (TS Exceptions: namespaces, function overloads, enums, and interfaces) + if (flags & (1536 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) { + continue; + } + var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); + if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + // it is legal to merge type alias with other values + // so count should be either 1 (just type alias) or 2 (type alias + merged value) + continue; + } + if (exportedDeclarationsCount > 1) { + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } @@ -27599,7 +28315,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 216 /* FunctionDeclaration */ || !!declaration.body; + return declaration.kind !== 217 /* FunctionDeclaration */ || !!declaration.body; } } function checkSourceElement(node) { @@ -27608,121 +28324,121 @@ var ts; } var kind = node.kind; if (cancellationToken) { - // Only bother checking on a few construct kinds. We don't want to be excessivly + // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 221 /* ModuleDeclaration */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: + case 222 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: return checkTypeParameter(node); - case 139 /* Parameter */: + case 140 /* Parameter */: return checkParameter(node); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return checkPropertyDeclaration(node); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: return checkSignatureDeclaration(node); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return checkMethodDeclaration(node); - case 145 /* Constructor */: + case 146 /* Constructor */: return checkConstructorDeclaration(node); - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return checkAccessorDeclaration(node); - case 152 /* TypeReference */: + case 153 /* TypeReference */: return checkTypeReferenceNode(node); - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: return checkTypePredicate(node); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return checkTypeQuery(node); - case 156 /* TypeLiteral */: + case 157 /* TypeLiteral */: return checkTypeLiteral(node); - case 157 /* ArrayType */: + case 158 /* ArrayType */: return checkArrayType(node); - case 158 /* TupleType */: + case 159 /* TupleType */: return checkTupleType(node); - case 159 /* UnionType */: - case 160 /* IntersectionType */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: return checkSourceElement(node.type); - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 195 /* Block */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return checkBlock(node); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return checkVariableStatement(node); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: return checkExpressionStatement(node); - case 199 /* IfStatement */: + case 200 /* IfStatement */: return checkIfStatement(node); - case 200 /* DoStatement */: + case 201 /* DoStatement */: return checkDoStatement(node); - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: return checkWhileStatement(node); - case 202 /* ForStatement */: + case 203 /* ForStatement */: return checkForStatement(node); - case 203 /* ForInStatement */: + case 204 /* ForInStatement */: return checkForInStatement(node); - case 204 /* ForOfStatement */: + case 205 /* ForOfStatement */: return checkForOfStatement(node); - case 205 /* ContinueStatement */: - case 206 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 207 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: return checkReturnStatement(node); - case 208 /* WithStatement */: + case 209 /* WithStatement */: return checkWithStatement(node); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: return checkSwitchStatement(node); - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return checkLabeledStatement(node); - case 211 /* ThrowStatement */: + case 212 /* ThrowStatement */: return checkThrowStatement(node); - case 212 /* TryStatement */: + case 213 /* TryStatement */: return checkTryStatement(node); - case 214 /* VariableDeclaration */: + case 215 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 166 /* BindingElement */: + case 167 /* BindingElement */: return checkBindingElement(node); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: return checkClassDeclaration(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: return checkImportDeclaration(node); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return checkExportDeclaration(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return checkExportAssignment(node); - case 197 /* EmptyStatement */: + case 198 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 213 /* DebuggerStatement */: + case 214 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 234 /* MissingDeclaration */: + case 235 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -27744,17 +28460,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: checkAccessorDeferred(node); break; - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -27829,7 +28545,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 208 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 209 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -27852,34 +28568,34 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 189 /* ClassExpression */: + case 190 /* 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 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* 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. // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 64 /* Static */)) { + if (!(memberFlags & 32 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 176 /* FunctionExpression */: + case 177 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -27928,37 +28644,48 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 138 /* TypeParameter */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 220 /* EnumDeclaration */: + case 139 /* TypeParameter */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 221 /* 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 === 136 /* QualifiedName */) { + while (node.parent && node.parent.kind === 137 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 152 /* TypeReference */; + return node.parent && node.parent.kind === 153 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 169 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 170 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 191 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 192 /* ExpressionWithTypeArguments */; + } + function isNodeWithinClass(node, classDeclaration) { + while (true) { + node = ts.getContainingClass(node); + if (!node) { + return false; + } + if (node === classDeclaration) { + return true; + } + } } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 136 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 137 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 225 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 230 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 231 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -27970,11 +28697,23 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 230 /* ExportAssignment */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 170 /* PropertyAccessExpression */) { + var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case 1 /* ExportsProperty */: + case 3 /* PrototypeProperty */: + return getSymbolOfNode(entityName.parent); + case 4 /* ThisProperty */: + case 2 /* ModuleExports */: + return getSymbolOfNode(entityName.parent.parent); + default: + } + } + if (entityName.parent.kind === 231 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 169 /* PropertyAccessExpression */) { + if (entityName.kind !== 170 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -27986,7 +28725,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 191 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 192 /* ExpressionWithTypeArguments */) { meaning = 793056 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -27999,10 +28738,10 @@ var ts; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 238 /* JsxOpeningElement */) || - (entityName.parent.kind === 237 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 240 /* JsxClosingElement */)) { - return getJsxElementTagSymbol(entityName.parent); + else if ((entityName.parent.kind === 239 /* JsxOpeningElement */) || + (entityName.parent.kind === 238 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 241 /* JsxClosingElement */)) { + return getJsxTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { @@ -28015,14 +28754,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 169 /* PropertyAccessExpression */) { + else if (entityName.kind === 170 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 136 /* QualifiedName */) { + else if (entityName.kind === 137 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -28031,16 +28770,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 152 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 153 /* 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 === 241 /* JsxAttribute */) { + else if (entityName.parent.kind === 242 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 151 /* TypePredicate */) { + if (entityName.parent.kind === 152 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -28057,12 +28796,12 @@ var ts; } if (node.kind === 69 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 230 /* ExportAssignment */ + return node.parent.kind === 231 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 166 /* BindingElement */ && - node.parent.parent.kind === 164 /* ObjectBindingPattern */ && + else if (node.parent.kind === 167 /* BindingElement */ && + node.parent.parent.kind === 165 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -28073,19 +28812,19 @@ var ts; } switch (node.kind) { case 69 /* Identifier */: - case 169 /* PropertyAccessExpression */: - case 136 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: + case 137 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97 /* ThisKeyword */: case 95 /* SuperKeyword */: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 162 /* ThisType */: + case 163 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 121 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 145 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 146 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -28093,14 +28832,14 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 225 /* ImportDeclaration */ || node.parent.kind === 231 /* ExportDeclaration */) && + ((node.parent.kind === 226 /* ImportDeclaration */ || node.parent.kind === 232 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 171 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -28117,7 +28856,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 === 249 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 250 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -28184,7 +28923,7 @@ var ts; */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 64 /* Static */ + return node.flags & 32 /* Static */ ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -28204,15 +28943,15 @@ var ts; } function getRootSymbols(symbol) { if (symbol.flags & 268435456 /* SyntheticProperty */) { - var symbols = []; - var name_18 = symbol.name; + var symbols_3 = []; + var name_17 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_18); + var symbol = getPropertyOfType(t, name_17); if (symbol) { - symbols.push(symbol); + symbols_3.push(symbol); } }); - return symbols; + return symbols_3; } else if (symbol.flags & 67108864 /* Transient */) { var target = getSymbolLinks(symbol).target; @@ -28232,7 +28971,7 @@ var ts; // module not found - be conservative return true; } - var hasExportAssignment = getExportAssignmentSymbol(moduleSymbol) !== undefined; + var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol); // if module has export assignment then 'resolveExternalModuleSymbol' will return resolved symbol for export assignment // otherwise it will return moduleSymbol itself moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); @@ -28267,11 +29006,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 251 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 252 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 221 /* ModuleDeclaration */ || n.kind === 220 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 222 /* ModuleDeclaration */ || n.kind === 221 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -28284,58 +29023,77 @@ var ts; var symbol = getReferencedValueSymbol(node); return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; } - function isStatementWithLocals(node) { - switch (node.kind) { - case 195 /* Block */: - case 223 /* CaseBlock */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - return true; - } - return false; - } - function isNestedRedeclarationSymbol(symbol) { + function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */) { var links = getSymbolLinks(symbol); - if (links.isNestedRedeclaration === undefined) { + if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (ts.isStatementWithLocals(container)) { + var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); + if (!!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + // redeclaration - always should be renamed + links.isDeclarationWithCollidingName = true; + } + else if (nodeLinks_1.flags & 131072 /* CapturedBlockScopedBinding */) { + // binding is captured in the function + // should be renamed if: + // - binding is not top level - top level bindings never collide with anything + // AND + // - binding is not declared in loop, should be renamed to avoid name reuse across siblings + // let a, b + // { let x = 1; a = () => x; } + // { let x = 100; b = () => x; } + // console.log(a()); // should print '1' + // console.log(b()); // should print '100' + // OR + // - binding is declared inside loop but not in inside initializer of iteration statement or directly inside loop body + // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly + // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus + // they will not collide with anything + var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; + var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 196 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); + } + else { + links.isDeclarationWithCollidingName = false; + } + } } - return links.isNestedRedeclaration; + return links.isDeclarationWithCollidingName; } return false; } // When resolved as an expression identifier, if the given node references a nested block scoped entity with - // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. - function getReferencedNestedRedeclaration(node) { + // a name that either hides an existing name or might hide it when compiled downlevel, + // return the declaration of that entity. Otherwise, return undefined. + function getReferencedDeclarationWithCollidingName(node) { var symbol = getReferencedValueSymbol(node); - return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + return symbol && isSymbolOfDeclarationWithCollidingName(symbol) ? symbol.valueDeclaration : undefined; } - // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an - // existing name. - function isNestedRedeclaration(node) { - return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + // Return true if the given node is a declaration of a nested block scoped entity with a name that either hides an + // existing name or might hide a name when compiled downlevel + function isDeclarationWithCollidingName(node) { + return isSymbolOfDeclarationWithCollidingName(getSymbolOfNode(node)); } function isValueAliasDeclaration(node) { switch (node.kind) { - case 224 /* ImportEqualsDeclaration */: - case 226 /* ImportClause */: - case 227 /* NamespaceImport */: - case 229 /* ImportSpecifier */: - case 233 /* ExportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 227 /* ImportClause */: + case 228 /* NamespaceImport */: + case 230 /* ImportSpecifier */: + case 234 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 251 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 252 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -28347,7 +29105,7 @@ var ts; if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } - // const enums and modules that contain only const enums are not considered values from the emit perespective + // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true return target !== unknownSymbol && target && @@ -28397,7 +29155,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 250 /* EnumMember */) { + if (node.kind === 251 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -28432,22 +29190,22 @@ var ts; else if (type.flags & 1 /* Any */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (allConstituentTypesHaveKind(type, 16 /* Void */)) { + else if (isTypeOfKind(type, 16 /* Void */)) { return ts.TypeReferenceSerializationKind.VoidType; } - else if (allConstituentTypesHaveKind(type, 8 /* Boolean */)) { + else if (isTypeOfKind(type, 8 /* Boolean */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (allConstituentTypesHaveKind(type, 132 /* NumberLike */)) { + else if (isTypeOfKind(type, 132 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (allConstituentTypesHaveKind(type, 258 /* StringLike */)) { + else if (isTypeOfKind(type, 258 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } - else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { + else if (isTypeOfKind(type, 8192 /* Tuple */)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { + else if (isTypeOfKind(type, 16777216 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -28493,8 +29251,8 @@ var ts; return { getReferencedExportContainer: getReferencedExportContainer, getReferencedImportDeclaration: getReferencedImportDeclaration, - getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, - isNestedRedeclaration: isNestedRedeclaration, + getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName, + isDeclarationWithCollidingName: isDeclarationWithCollidingName, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -28523,7 +29281,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 251 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 252 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -28536,7 +29294,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } - if (file.moduleAugmentations) { + if (file.moduleAugmentations.length) { (augmentations || (augmentations = [])).push(file.moduleAugmentations); } }); @@ -28599,6 +29357,9 @@ var ts; globalIterableIteratorType = emptyGenericType; } anyArrayType = createArrayType(anyType); + var symbol = getGlobalSymbol("ReadonlyArray", 793056 /* Type */, /*diagnostic*/ undefined); + globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); + anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); @@ -28624,14 +29385,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 144 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 145 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 146 /* GetAccessor */ || node.kind === 147 /* SetAccessor */) { + else if (node.kind === 147 /* GetAccessor */ || node.kind === 148 /* 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); @@ -28641,38 +29402,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 145 /* Constructor */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 150 /* IndexSignature */: - case 221 /* ModuleDeclaration */: - case 225 /* ImportDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 231 /* ExportDeclaration */: - case 230 /* ExportAssignment */: - case 139 /* Parameter */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 146 /* Constructor */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 151 /* IndexSignature */: + case 222 /* ModuleDeclaration */: + case 226 /* ImportDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 232 /* ExportDeclaration */: + case 231 /* ExportAssignment */: + case 140 /* Parameter */: break; - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && - node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { + node.parent.kind !== 223 /* ModuleBlock */ && node.parent.kind !== 252 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 196 /* VariableStatement */: - case 219 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 197 /* VariableStatement */: + case 220 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 223 /* ModuleBlock */ && node.parent.kind !== 252 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && - node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { + node.parent.kind !== 223 /* ModuleBlock */ && node.parent.kind !== 252 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -28682,42 +29443,48 @@ var ts; if (!node.modifiers) { return; } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync, lastReadonly; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; + if (modifier.kind !== 127 /* ReadonlyKeyword */) { + if (node.kind === 142 /* PropertySignature */ || node.kind === 144 /* MethodSignature */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); + } + if (node.kind === 151 /* IndexSignature */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); + } + } switch (modifier.kind) { case 74 /* ConstKeyword */: - if (node.kind !== 220 /* EnumDeclaration */ && node.parent.kind === 217 /* ClassDeclaration */) { + if (node.kind !== 221 /* EnumDeclaration */ && node.parent.kind === 218 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74 /* ConstKeyword */)); } break; case 112 /* PublicKeyword */: case 111 /* ProtectedKeyword */: case 110 /* PrivateKeyword */: - var text = void 0; - if (modifier.kind === 112 /* PublicKeyword */) { - text = "public"; - } - else if (modifier.kind === 111 /* ProtectedKeyword */) { - text = "protected"; + var text = visibilityToString(ts.modifierToFlag(modifier.kind)); + if (modifier.kind === 111 /* ProtectedKeyword */) { lastProtected = modifier; } - else { - text = "private"; + else if (modifier.kind === 110 /* PrivateKeyword */) { lastPrivate = modifier; } - if (flags & 56 /* AccessibilityModifier */) { + if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 64 /* Static */) { + else if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + else if (node.parent.kind === 223 /* ModuleBlock */ || node.parent.kind === 252 /* SourceFile */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { if (modifier.kind === 110 /* PrivateKeyword */) { @@ -28730,29 +29497,42 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113 /* StaticKeyword */: - if (flags & 64 /* Static */) { + if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + else if (node.parent.kind === 223 /* ModuleBlock */ || node.parent.kind === 252 /* SourceFile */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 139 /* Parameter */) { + else if (node.kind === 140 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 64 /* Static */; + flags |= 32 /* Static */; lastStatic = modifier; break; + case 127 /* ReadonlyKeyword */: + if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); + } + else if (node.kind !== 143 /* PropertyDeclaration */ && node.kind !== 142 /* PropertySignature */ && node.kind !== 151 /* IndexSignature */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); + } + flags |= 64 /* Readonly */; + lastReadonly = modifier; + break; case 82 /* ExportKeyword */: - if (flags & 2 /* Export */) { + if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 4 /* Ambient */) { + else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } else if (flags & 128 /* Abstract */) { @@ -28761,48 +29541,51 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 217 /* ClassDeclaration */) { + else if (node.parent.kind === 218 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 139 /* Parameter */) { + else if (node.kind === 140 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 2 /* Export */; + flags |= 1 /* Export */; break; case 122 /* DeclareKeyword */: - if (flags & 4 /* Ambient */) { + if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 217 /* ClassDeclaration */) { + else if (node.parent.kind === 218 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 139 /* Parameter */) { + else if (node.kind === 140 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 222 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 223 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 4 /* Ambient */; + flags |= 2 /* Ambient */; lastDeclare = modifier; break; case 115 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 217 /* ClassDeclaration */) { - if (node.kind !== 144 /* MethodDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + if (node.kind !== 218 /* ClassDeclaration */) { + if (node.kind !== 145 /* MethodDeclaration */ && + node.kind !== 143 /* PropertyDeclaration */ && + node.kind !== 147 /* GetAccessor */ && + node.kind !== 148 /* SetAccessor */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 217 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { + if (!(node.parent.kind === 218 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 64 /* Static */) { + if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 16 /* Private */) { + if (flags & 8 /* Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } @@ -28812,10 +29595,10 @@ var ts; if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 4 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + 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 === 139 /* Parameter */) { + else if (node.kind === 140 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -28823,28 +29606,25 @@ var ts; break; } } - if (node.kind === 145 /* Constructor */) { - if (flags & 64 /* Static */) { + if (node.kind === 146 /* Constructor */) { + if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 32 /* Protected */) { - return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & 16 /* Private */) { - return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly"); + } return; } - else if ((node.kind === 225 /* ImportDeclaration */ || node.kind === 224 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { + else if ((node.kind === 226 /* ImportDeclaration */ || node.kind === 225 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 139 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 140 /* Parameter */ && (flags & 28 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 256 /* Async */) { @@ -28856,10 +29636,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 144 /* MethodDeclaration */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -28925,7 +29705,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 177 /* ArrowFunction */) { + if (node.kind === 178 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -28948,7 +29728,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 1022 /* Modifier */) { + if (parameter.flags & 959 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -28960,21 +29740,16 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { + if (parameter.type.kind !== 131 /* StringKeyword */ && parameter.type.kind !== 129 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); } } - function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 1022 /* Modifier */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } function checkGrammarIndexSignature(node) { // Prevent cascading error by short-circuit - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node); } function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { if (typeArguments && typeArguments.length === 0) { @@ -28993,7 +29768,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { var arg = args_1[_i]; - if (arg.kind === 190 /* OmittedExpression */) { + if (arg.kind === 191 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -29067,19 +29842,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 137 /* ComputedPropertyName */) { + if (node.kind !== 138 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 184 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 185 /* 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 === 216 /* FunctionDeclaration */ || - node.kind === 176 /* FunctionExpression */ || - node.kind === 144 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 217 /* FunctionDeclaration */ || + node.kind === 177 /* FunctionExpression */ || + node.kind === 145 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -29100,28 +29875,28 @@ var ts; var seen = {}; var Property = 1; var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; + var SetAccessor = 4; + var GetOrSetAccessor = GetAccessor | SetAccessor; var _loop_1 = function(prop) { - var name_19 = prop.name; - if (prop.kind === 190 /* OmittedExpression */ || - name_19.kind === 137 /* ComputedPropertyName */) { + var name_18 = prop.name; + if (prop.kind === 191 /* OmittedExpression */ || + name_18.kind === 138 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_19); + checkGrammarComputedPropertyName(name_18); return "continue"; } - if (prop.kind === 249 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 250 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) }; } // Modifiers are never allowed on properties except for 'async' on a method declaration ts.forEach(prop.modifiers, function (mod) { - if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 144 /* MethodDeclaration */) { + if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 145 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } }); - // ECMA-262 11.1.5 Object Initialiser + // ECMA-262 11.1.5 Object Initializer // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and // IsDataDescriptor(propId.descriptor) is true. @@ -29130,71 +29905,71 @@ 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 === 248 /* PropertyAssignment */ || prop.kind === 249 /* ShorthandPropertyAssignment */) { - // Grammar checking for computedPropertName and shorthandPropertyAssignment + if (prop.kind === 249 /* PropertyAssignment */ || prop.kind === 250 /* ShorthandPropertyAssignment */) { + // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_19.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_19); + if (name_18.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_18); } currentKind = Property; } - else if (prop.kind === 144 /* MethodDeclaration */) { + else if (prop.kind === 145 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 146 /* GetAccessor */) { + else if (prop.kind === 147 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 147 /* SetAccessor */) { - currentKind = SetAccesor; + else if (prop.kind === 148 /* SetAccessor */) { + currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_19.text)) { - seen[name_19.text] = currentKind; + if (!ts.hasProperty(seen, name_18.text)) { + seen[name_18.text] = currentKind; } else { - var existingKind = seen[name_19.text]; + var existingKind = seen[name_18.text]; if (currentKind === Property && existingKind === Property) { return "continue"; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_19.text] = currentKind | existingKind; + seen[name_18.text] = currentKind | existingKind; } else { - return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; + return { value: grammarErrorOnNode(name_18, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; } } else { - return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; + return { value: grammarErrorOnNode(name_18, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; } } }; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var state_1 = _loop_1(prop); - if (typeof state_1 === "object") return state_1.value - if (state_1 === "continue") continue; + var state_2 = _loop_1(prop); + if (typeof state_2 === "object") return state_2.value; + if (state_2 === "continue") continue; } } function checkGrammarJsxElement(node) { var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 242 /* JsxSpreadAttribute */) { + if (attr.kind === 243 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_20 = jsxAttr.name; - if (!ts.hasProperty(seen, name_20.text)) { - seen[name_20.text] = true; + var name_19 = jsxAttr.name; + if (!ts.hasProperty(seen, name_19.text)) { + seen[name_19.text] = true; } else { - return grammarErrorOnNode(name_20, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_19, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 243 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 244 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -29203,7 +29978,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 215 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 216 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -29218,20 +29993,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 203 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 204 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 203 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 204 /* 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 === 203 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 204 /* 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); @@ -29248,16 +30023,16 @@ var ts; else if (ts.isInAmbientContext(accessor)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); } - else if (accessor.body === undefined) { + else if (accessor.body === undefined && !(accessor.flags & 128 /* Abstract */)) { return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 146 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 147 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 147 /* SetAccessor */) { + else if (kind === 148 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -29269,7 +30044,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 1022 /* Modifier */) { + else if (parameter.flags & 959 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -29292,7 +30067,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 168 /* ObjectLiteralExpression */) { + if (node.parent.kind === 169 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -29316,10 +30091,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 218 /* InterfaceDeclaration */) { + else if (node.parent.kind === 219 /* 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 === 156 /* TypeLiteral */) { + else if (node.parent.kind === 157 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -29330,11 +30105,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 210 /* LabeledStatement */: + case 211 /* 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 === 205 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 206 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -29342,8 +30117,8 @@ var ts; return false; } break; - case 209 /* SwitchStatement */: - if (node.kind === 206 /* BreakStatement */ && !node.label) { + case 210 /* SwitchStatement */: + if (node.kind === 207 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -29358,13 +30133,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 206 /* BreakStatement */ + var message = node.kind === 207 /* 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 === 206 /* BreakStatement */ + var message = node.kind === 207 /* 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); @@ -29376,7 +30151,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 === 165 /* ArrayBindingPattern */ || node.name.kind === 164 /* ObjectBindingPattern */) { + if (node.name.kind === 166 /* ArrayBindingPattern */ || node.name.kind === 165 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -29386,7 +30161,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 203 /* ForInStatement */ && node.parent.parent.kind !== 204 /* ForOfStatement */) { + if (node.parent.parent.kind !== 204 /* ForInStatement */ && node.parent.parent.kind !== 205 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -29422,7 +30197,7 @@ var ts; var elements = name.elements; for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { var element = elements_2[_i]; - if (element.kind !== 190 /* OmittedExpression */) { + if (element.kind !== 191 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -29439,15 +30214,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 199 /* IfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 208 /* WithStatement */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 200 /* IfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 209 /* WithStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: return false; - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -29503,7 +30278,7 @@ var ts; return true; } } - else if (node.parent.kind === 218 /* InterfaceDeclaration */) { + else if (node.parent.kind === 219 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -29511,7 +30286,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 156 /* TypeLiteral */) { + else if (node.parent.kind === 157 /* 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; } @@ -29536,14 +30311,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 218 /* InterfaceDeclaration */ || - node.kind === 219 /* TypeAliasDeclaration */ || - node.kind === 225 /* ImportDeclaration */ || - node.kind === 224 /* ImportEqualsDeclaration */ || - node.kind === 231 /* ExportDeclaration */ || - node.kind === 230 /* ExportAssignment */ || - (node.flags & 4 /* Ambient */) || - (node.flags & (2 /* Export */ | 512 /* Default */))) { + if (node.kind === 219 /* InterfaceDeclaration */ || + node.kind === 220 /* TypeAliasDeclaration */ || + node.kind === 226 /* ImportDeclaration */ || + node.kind === 225 /* ImportEqualsDeclaration */ || + node.kind === 232 /* ExportDeclaration */ || + node.kind === 231 /* ExportAssignment */ || + (node.flags & 2 /* Ambient */) || + (node.flags & (1 /* Export */ | 512 /* Default */))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -29551,7 +30326,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 === 196 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 197 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -29574,10 +30349,10 @@ var ts; } // We are either parented by another statement, or some sort of block. // If we're in a block, we only want to really report an error once - // to prevent noisyness. So use a bit on the block to indicate if + // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 195 /* Block */ || node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { + if (node.parent.kind === 196 /* Block */ || node.parent.kind === 223 /* ModuleBlock */ || node.parent.kind === 252 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -29590,7 +30365,7 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 32768 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + if (node.isOctalLiteral && languageVersion >= 1 /* ES5 */) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -29611,6 +30386,14 @@ var ts; var ts; (function (ts) { var nullSourceMapWriter; + // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans + var defaultLastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; function getNullSourceMapWriter() { if (nullSourceMapWriter === undefined) { nullSourceMapWriter = { @@ -29664,13 +30447,7 @@ var ts; sourceMapSourceIndex = -1; // Last recorded and encoded spans lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; + lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; lastEncodedNameIndex = 0; // Initialize source map data sourceMapData = { @@ -29733,10 +30510,12 @@ var ts; lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; // Pop sourceMapDecodedMappings to remove last entry sourceMapData.sourceMapDecodedMappings.pop(); - // Change the last encoded source map + // Point the lastEncodedSourceMapSpace to the previous encoded sourceMapSpan + // If the list is empty which indicates that we are at the beginning of the file, + // we have to reset it to default value (same value when we first initialize sourceMapWriter) lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - undefined; + defaultLastEncodedSourceMapSpan; // TODO: Update lastEncodedNameIndex // Since we dont support this any more, lets not worry about it right now. // When we start supporting nameIndex, we will get back to this @@ -29944,7 +30723,8 @@ var ts; var increaseIndent; var decreaseIndent; var writeTextOfNode; - var writer = createAndSetNewTextWriterWithSymbolWriter(); + var writer; + createAndSetNewTextWriterWithSymbolWriter(); var enclosingDeclaration; var resultHasExternalModuleIndicator; var currentText; @@ -30008,7 +30788,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 225 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 226 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -30064,7 +30844,6 @@ var ts; writer.writeParameter = writer.write; writer.writeSymbol = writer.write; setWriter(writer); - return writer; } function setWriter(newWriter) { writer = newWriter; @@ -30078,10 +30857,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 214 /* VariableDeclaration */) { + if (declaration.kind === 215 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 228 /* NamedImports */ || declaration.kind === 229 /* ImportSpecifier */ || declaration.kind === 226 /* ImportClause */) { + else if (declaration.kind === 229 /* NamedImports */ || declaration.kind === 230 /* ImportSpecifier */ || declaration.kind === 227 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -30099,7 +30878,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 === 225 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 226 /* 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; @@ -30109,12 +30888,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 221 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 222 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 221 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 222 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -30124,23 +30903,23 @@ var ts; }); setWriter(oldWriter); } - function handleSymbolAccessibilityError(symbolAccesibilityResult) { - if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { + function handleSymbolAccessibilityError(symbolAccessibilityResult) { + if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { // write the aliases - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccessibilityResult.aliasesToMakeVisible); } } else { // Report error reportedDeclarationError = true; - var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccessibilityResult); if (errorInfo) { if (errorInfo.typeName) { - emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNodeFromSourceText(currentText, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNodeFromSourceText(currentText, errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } else { - emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } } } @@ -30217,40 +30996,40 @@ var ts; function emitType(type) { switch (type.kind) { case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: case 103 /* VoidKeyword */: - case 162 /* ThisType */: - case 163 /* StringLiteralType */: + case 163 /* ThisType */: + case 164 /* StringLiteralType */: return writeTextOfNode(currentText, type); - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 152 /* TypeReference */: + case 153 /* TypeReference */: return emitTypeReference(type); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return emitTypeQuery(type); - case 157 /* ArrayType */: + case 158 /* ArrayType */: return emitArrayType(type); - case 158 /* TupleType */: + case 159 /* TupleType */: return emitTupleType(type); - case 159 /* UnionType */: + case 160 /* UnionType */: return emitUnionType(type); - case 160 /* IntersectionType */: + case 161 /* IntersectionType */: return emitIntersectionType(type); - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: return emitParenType(type); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 156 /* TypeLiteral */: + case 157 /* TypeLiteral */: return emitTypeLiteral(type); case 69 /* Identifier */: return emitEntityName(type); - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return emitEntityName(type); - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -30258,8 +31037,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 136 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 136 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 137 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 137 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -30268,13 +31047,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 224 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 225 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 169 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 170 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -30353,9 +31132,9 @@ var ts; var count = 0; while (true) { count++; - var name_21 = baseName + "_" + count; - if (!ts.hasProperty(currentIdentifiers, name_21)) { - return name_21; + var name_20 = baseName + "_" + count; + if (!ts.hasProperty(currentIdentifiers, name_20)) { + return name_20; } } } @@ -30399,10 +31178,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 224 /* ImportEqualsDeclaration */ || - (node.parent.kind === 251 /* SourceFile */ && isCurrentFileExternalModule)) { - var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 251 /* SourceFile */) { + else if (node.kind === 225 /* ImportEqualsDeclaration */ || + (node.parent.kind === 252 /* SourceFile */ && isCurrentFileExternalModule)) { + var isVisible = void 0; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 252 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -30412,7 +31191,7 @@ var ts; }); } else { - if (node.kind === 225 /* ImportDeclaration */) { + if (node.kind === 226 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -30430,23 +31209,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return writeVariableStatement(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: return writeClassDeclaration(node); - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -30454,30 +31233,33 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 251 /* SourceFile */) { + if (node.parent.kind === 252 /* SourceFile */) { // If the node is exported - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { write("export "); } if (node.flags & 512 /* Default */) { write("default "); } - else if (node.kind !== 218 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 219 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } } - function emitClassMemberDeclarationFlags(node) { - if (node.flags & 16 /* Private */) { + function emitClassMemberDeclarationFlags(flags) { + if (flags & 8 /* Private */) { write("private "); } - else if (node.flags & 32 /* Protected */) { + else if (flags & 16 /* Protected */) { write("protected "); } - if (node.flags & 64 /* Static */) { + if (flags & 32 /* Static */) { write("static "); } - if (node.flags & 128 /* Abstract */) { + if (flags & 64 /* Readonly */) { + write("readonly "); + } + if (flags & 128 /* Abstract */) { write("abstract "); } } @@ -30485,7 +31267,7 @@ var ts; // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { write("export "); } write("import "); @@ -30501,7 +31283,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult) { + function getImportEntityNameVisibilityError(symbolAccessibilityResult) { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -30511,7 +31293,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 227 /* NamespaceImport */) { + if (namedBindings.kind === 228 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -30520,12 +31302,8 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 2 /* Export */)) { - // do not write non-exported import declarations that don't have import clauses - return; - } emitJsDocComments(node); - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { write("export "); } write("import "); @@ -30539,7 +31317,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 228 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -30558,15 +31336,15 @@ var ts; function emitExternalModuleSpecifier(parent) { // emitExternalModuleSpecifier is usually called when we emit something in the.d.ts file that will make it an external module (i.e. import/export declarations). // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered - // external modules since they are indistingushable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' + // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 221 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 222 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 224 /* ImportEqualsDeclaration */) { + if (parent.kind === 225 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 221 /* ModuleDeclaration */) { + else if (parent.kind === 222 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -30623,7 +31401,7 @@ var ts; write("global "); } else { - if (node.flags & 65536 /* Namespace */) { + if (node.flags & 4096 /* Namespace */) { write("namespace "); } else { @@ -30636,7 +31414,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body.kind !== 222 /* ModuleBlock */) { + while (node.body.kind !== 223 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -30665,7 +31443,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -30701,7 +31479,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 144 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); + return node.parent.kind === 145 /* MethodDeclaration */ && (node.parent.flags & 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -30712,50 +31490,50 @@ 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 === 153 /* FunctionType */ || - node.parent.kind === 154 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 156 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 144 /* MethodDeclaration */ || - node.parent.kind === 143 /* MethodSignature */ || - node.parent.kind === 153 /* FunctionType */ || - node.parent.kind === 154 /* ConstructorType */ || - node.parent.kind === 148 /* CallSignature */ || - node.parent.kind === 149 /* ConstructSignature */); + if (node.parent.kind === 154 /* FunctionType */ || + node.parent.kind === 155 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 157 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 145 /* MethodDeclaration */ || + node.parent.kind === 144 /* MethodSignature */ || + node.parent.kind === 154 /* FunctionType */ || + node.parent.kind === 155 /* ConstructorType */ || + node.parent.kind === 149 /* CallSignature */ || + node.parent.kind === 150 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 148 /* CallSignature */: + case 149 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - if (node.parent.flags & 64 /* Static */) { + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + if (node.parent.flags & 32 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 217 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 218 /* 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 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -30786,10 +31564,10 @@ var ts; else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { write("null"); } - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + function getHeritageClauseVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 217 /* ClassDeclaration */) { + if (node.parent.parent.kind === 218 /* 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 : @@ -30811,7 +31589,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 56 /* AccessibilityModifier */) { + if (param.flags & 28 /* AccessibilityModifier */) { emitPropertyDeclaration(param); } }); @@ -30865,7 +31643,7 @@ var ts; return; } emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags); emitVariableDeclaration(node); write(";"); writeLine(); @@ -30873,7 +31651,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 !== 214 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 215 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -30883,51 +31661,51 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentText, node.name); // If optional property emit ? - if ((node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 143 /* PropertyDeclaration */ || node.kind === 142 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) && node.parent.kind === 156 /* TypeLiteral */) { + if ((node.kind === 143 /* PropertyDeclaration */ || node.kind === 142 /* PropertySignature */) && node.parent.kind === 157 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 16 /* Private */)) { + else if (!(node.flags & 8 /* Private */)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 214 /* VariableDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { + if (node.kind === 215 /* VariableDeclaration */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) { + else if (node.kind === 143 /* PropertyDeclaration */ || node.kind === 142 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. - if (node.flags & 64 /* Static */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + if (node.flags & 32 /* Static */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 217 /* ClassDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + else if (node.parent.kind === 218 /* ClassDeclaration */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { // Interfaces cannot have types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; } } } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, @@ -30943,15 +31721,15 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 190 /* OmittedExpression */) { + if (element.kind !== 191 /* OmittedExpression */) { elements.push(element); } } emitCommaList(elements, emitBindingElement); } function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getBindingElementTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: bindingElement, @@ -31006,14 +31784,14 @@ var ts; if (node === accessors.firstAccessor) { emitJsDocComments(accessors.getAccessor); emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags | (accessors.setAccessor ? 0 : 64 /* Readonly */)); writeTextOfNode(currentText, node.name); - if (!(node.flags & 16 /* Private */)) { + if (!(node.flags & 8 /* Private */)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 146 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 147 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -31026,24 +31804,24 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 146 /* GetAccessor */ + return accessor.kind === 147 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type : undefined; } } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 147 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 148 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named - if (accessorWithTypeAnnotation.parent.flags & 64 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + if (accessorWithTypeAnnotation.parent.flags & 32 /* Static */) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; } @@ -31055,16 +31833,16 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 64 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + if (accessorWithTypeAnnotation.flags & 32 /* Static */) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; @@ -31085,17 +31863,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 216 /* FunctionDeclaration */) { + if (node.kind === 217 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 144 /* MethodDeclaration */) { - emitClassMemberDeclarationFlags(node); + else if (node.kind === 145 /* MethodDeclaration */ || node.kind === 146 /* Constructor */) { + emitClassMemberDeclarationFlags(node.flags); } - if (node.kind === 216 /* FunctionDeclaration */) { + if (node.kind === 217 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 145 /* Constructor */) { + else if (node.kind === 146 /* Constructor */) { write("constructor"); } else { @@ -31114,35 +31892,37 @@ var ts; function emitSignatureDeclaration(node) { var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; - // Construct signature or constructor type write new Signature - if (node.kind === 149 /* ConstructSignature */ || node.kind === 154 /* ConstructorType */) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 150 /* IndexSignature */) { + if (node.kind === 151 /* IndexSignature */) { + // Index signature can have readonly modifier + emitClassMemberDeclarationFlags(node.flags); write("["); } else { + // Construct signature or constructor type write new Signature + if (node.kind === 150 /* ConstructSignature */ || node.kind === 155 /* ConstructorType */) { + write("new "); + } + emitTypeParameters(node.typeParameters); write("("); } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 150 /* IndexSignature */) { + if (node.kind === 151 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 153 /* FunctionType */ || node.kind === 154 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 156 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 154 /* FunctionType */ || node.kind === 155 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 157 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 145 /* Constructor */ && !(node.flags & 16 /* Private */)) { + else if (node.kind !== 146 /* Constructor */ && !(node.flags & 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -31150,53 +31930,53 @@ var ts; write(";"); writeLine(); } - function getReturnTypeVisibilityError(symbolAccesibilityResult) { + function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 148 /* CallSignature */: + case 149 /* CallSignature */: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - if (node.flags & 64 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + if (node.flags & 32 /* Static */) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : 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 === 217 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + else if (node.parent.kind === 218 /* ClassDeclaration */) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 216 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 217 /* FunctionDeclaration */: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -31229,65 +32009,65 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 153 /* FunctionType */ || - node.parent.kind === 154 /* ConstructorType */ || - node.parent.parent.kind === 156 /* TypeLiteral */) { + if (node.parent.kind === 154 /* FunctionType */ || + node.parent.kind === 155 /* ConstructorType */ || + node.parent.parent.kind === 157 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 16 /* Private */)) { + else if (!(node.parent.flags & 8 /* Private */)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, typeName: node.name } : undefined; } - function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 145 /* Constructor */: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 146 /* Constructor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 148 /* CallSignature */: + case 149 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - if (node.parent.flags & 64 /* Static */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + if (node.parent.flags & 32 /* Static */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 217 /* ClassDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + else if (node.parent.parent.kind === 218 /* ClassDeclaration */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? 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 216 /* FunctionDeclaration */: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 217 /* FunctionDeclaration */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; @@ -31297,12 +32077,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 === 164 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 165 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 165 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 166 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -31313,7 +32093,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 190 /* OmittedExpression */) { + if (bindingElement.kind === 191 /* 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) @@ -31322,7 +32102,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 166 /* BindingElement */) { + else if (bindingElement.kind === 167 /* 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" @@ -31361,40 +32141,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 216 /* FunctionDeclaration */: - case 221 /* ModuleDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 218 /* InterfaceDeclaration */: - case 217 /* ClassDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 220 /* EnumDeclaration */: + case 217 /* FunctionDeclaration */: + case 222 /* ModuleDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 219 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 221 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return emitExportDeclaration(node); - case 145 /* Constructor */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 146 /* Constructor */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return writeFunctionDeclaration(node); - case 149 /* ConstructSignature */: - case 148 /* CallSignature */: - case 150 /* IndexSignature */: + case 150 /* ConstructSignature */: + case 149 /* CallSignature */: + case 151 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return emitAccessorDeclaration(node); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return emitPropertyDeclaration(node); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return emitExportAssignment(node); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return emitSourceFile(node); } } @@ -31744,6 +32524,11 @@ var ts; TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; TempFlags[TempFlags["_i"] = 268435456] = "_i"; })(TempFlags || (TempFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function @@ -31754,7 +32539,7 @@ var ts; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; // emit output for the __param helper function var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new P(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.call(thisArg, _arguments)).next());\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -31830,9 +32615,11 @@ var ts; // => // var x;... exporter("x", x = 1) var exportFunctionForFile; + var contextObjectForFile; var generatedNameSet; var nodeToGeneratedName; var computedPropertyNamesToGeneratedNames; + var decoratedClassAliases; var convertedLoopState; var extendsEmitted; var decorateEmitted; @@ -31854,19 +32641,19 @@ var ts; var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; var setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer) { }; var moduleEmitDelegates = (_a = {}, - _a[5 /* ES6 */] = emitES6Module, - _a[2 /* AMD */] = emitAMDModule, - _a[4 /* System */] = emitSystemModule, - _a[3 /* UMD */] = emitUMDModule, - _a[1 /* CommonJS */] = emitCommonJSModule, + _a[ts.ModuleKind.ES6] = emitES6Module, + _a[ts.ModuleKind.AMD] = emitAMDModule, + _a[ts.ModuleKind.System] = emitSystemModule, + _a[ts.ModuleKind.UMD] = emitUMDModule, + _a[ts.ModuleKind.CommonJS] = emitCommonJSModule, _a ); var bundleEmitDelegates = (_b = {}, - _b[5 /* ES6 */] = function () { }, - _b[2 /* AMD */] = emitAMDModule, - _b[4 /* System */] = emitSystemModule, - _b[3 /* UMD */] = function () { }, - _b[1 /* CommonJS */] = function () { }, + _b[ts.ModuleKind.ES6] = function () { }, + _b[ts.ModuleKind.AMD] = emitAMDModule, + _b[ts.ModuleKind.System] = emitSystemModule, + _b[ts.ModuleKind.UMD] = function () { }, + _b[ts.ModuleKind.CommonJS] = function () { }, _b ); return doEmit; @@ -31874,6 +32661,7 @@ var ts; sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); generatedNameSet = {}; nodeToGeneratedName = []; + decoratedClassAliases = []; isOwnFileEmit = !isBundledEmit; // Emit helpers from all the files if (isBundledEmit && modulekind) { @@ -31894,8 +32682,10 @@ var ts; currentText = undefined; currentLineMap = undefined; exportFunctionForFile = undefined; + contextObjectForFile = undefined; generatedNameSet = undefined; nodeToGeneratedName = undefined; + decoratedClassAliases = undefined; computedPropertyNamesToGeneratedNames = undefined; convertedLoopState = undefined; extendsEmitted = false; @@ -31920,6 +32710,7 @@ var ts; currentText = sourceFile.text; currentLineMap = ts.getLineStarts(sourceFile); exportFunctionForFile = undefined; + contextObjectForFile = undefined; isEs6Module = sourceFile.symbol && sourceFile.symbol.exports && !!sourceFile.symbol.exports["___esModule"]; renamedDependencies = sourceFile.renamedDependencies; currentFileIdentifiers = sourceFile.identifiers; @@ -31937,10 +32728,10 @@ var ts; // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_22 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_22)) { + var name_21 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_21)) { tempFlags |= flags; - return name_22; + return name_21; } } while (true) { @@ -31948,9 +32739,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_23 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_23)) { - return name_23; + var name_22 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_22)) { + return name_22; } } } @@ -31994,17 +32785,17 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return makeUniqueName(node.text); - case 221 /* ModuleDeclaration */: - case 220 /* EnumDeclaration */: + case 222 /* ModuleDeclaration */: + case 221 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 225 /* ImportDeclaration */: - case 231 /* ExportDeclaration */: + case 226 /* ImportDeclaration */: + case 232 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 216 /* FunctionDeclaration */: - case 217 /* ClassDeclaration */: - case 230 /* ExportAssignment */: + case 217 /* FunctionDeclaration */: + case 218 /* ClassDeclaration */: + case 231 /* ExportAssignment */: return generateNameForExportDefault(); - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -32232,7 +33023,7 @@ var ts; // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". var text = ts.getTextOfNodeFromSourceText(currentText, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // text contains the original source, it will also contain quotes ("`"), dollar signs and braces ("${" and "}"), // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" @@ -32274,10 +33065,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 186 /* TemplateExpression */) { + if (node.template.kind === 187 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 184 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 185 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -32312,7 +33103,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 175 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 176 /* 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 @@ -32354,11 +33145,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return parent.expression === template; - case 173 /* TaggedTemplateExpression */: - case 175 /* ParenthesizedExpression */: + case 174 /* TaggedTemplateExpression */: + case 176 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -32379,7 +33170,7 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 37 /* AsteriskToken */: case 39 /* SlashToken */: @@ -32391,8 +33182,8 @@ var ts; default: return -1 /* LessThan */; } - case 187 /* YieldExpression */: - case 185 /* ConditionalExpression */: + case 188 /* YieldExpression */: + case 186 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -32459,12 +33250,12 @@ 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 === 242 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 243 /* JsxSpreadAttribute */; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; for (var i = 0; i < attrs.length; i++) { - if (attrs[i].kind === 242 /* JsxSpreadAttribute */) { + if (attrs[i].kind === 243 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument if (i === 0) { write("{}, "); @@ -32479,7 +33270,7 @@ var ts; emit(attrs[i].expression); } else { - ts.Debug.assert(attrs[i].kind === 241 /* JsxAttribute */); + ts.Debug.assert(attrs[i].kind === 242 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } @@ -32511,23 +33302,45 @@ var ts; } // Children if (children) { - for (var i = 0; i < children.length; i++) { - // Don't emit empty expressions - if (children[i].kind === 243 /* JsxExpression */ && !(children[i].expression)) { - continue; - } - // Don't emit empty strings - if (children[i].kind === 239 /* JsxText */) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); + var firstChild = void 0; + var multipleEmittableChildren = false; + for (var i = 0, n = children.length; i < n; i++) { + var jsxChild = children[i]; + if (isJsxChildEmittable(jsxChild)) { + // we need to decide whether to emit in single line or multiple lines as indented list + // store firstChild reference, if we see another emittable child, then emit accordingly + if (!firstChild) { + write(", "); + firstChild = jsxChild; + } + else { + // more than one emittable child, emit indented list + if (!multipleEmittableChildren) { + multipleEmittableChildren = true; + increaseIndent(); + writeLine(); + emit(firstChild); + } + write(", "); + writeLine(); + emit(jsxChild); } } + } + if (multipleEmittableChildren) { + decreaseIndent(); + } + else if (firstChild) { + if (firstChild.kind !== 237 /* JsxElement */ && firstChild.kind !== 238 /* JsxSelfClosingElement */) { + emit(firstChild); + } else { - write(", "); - emit(children[i]); + // If the only child is jsx element, put it on a new indented line + increaseIndent(); + writeLine(); + emit(firstChild); + writeLine(); + decreaseIndent(); } } } @@ -32535,11 +33348,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 236 /* JsxElement */) { + if (node.kind === 237 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 237 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 238 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -32561,11 +33374,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 242 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 243 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 241 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 242 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -32573,11 +33386,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 237 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 238 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 237 /* JsxSelfClosingElement */) { + if (node.kind === 238 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -32596,11 +33409,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 236 /* JsxElement */) { + if (node.kind === 237 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 237 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 238 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -32608,11 +33421,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 !== 166 /* BindingElement */); + ts.Debug.assert(node.kind !== 167 /* BindingElement */); if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 137 /* ComputedPropertyName */) { + else if (node.kind === 138 /* 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: @@ -32656,76 +33469,72 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* ArrayLiteralExpression */: - case 192 /* AsExpression */: - case 184 /* BinaryExpression */: - case 171 /* CallExpression */: - case 244 /* CaseClause */: - case 137 /* ComputedPropertyName */: - case 185 /* ConditionalExpression */: - case 140 /* Decorator */: - case 178 /* DeleteExpression */: - case 200 /* DoStatement */: - case 170 /* ElementAccessExpression */: - case 230 /* ExportAssignment */: - case 198 /* ExpressionStatement */: - case 191 /* ExpressionWithTypeArguments */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 199 /* IfStatement */: - case 240 /* JsxClosingElement */: - case 237 /* JsxSelfClosingElement */: - case 238 /* JsxOpeningElement */: - case 242 /* JsxSpreadAttribute */: - case 243 /* JsxExpression */: - case 172 /* NewExpression */: - case 175 /* ParenthesizedExpression */: - case 183 /* PostfixUnaryExpression */: - case 182 /* PrefixUnaryExpression */: - case 207 /* ReturnStatement */: - case 249 /* ShorthandPropertyAssignment */: - case 188 /* SpreadElementExpression */: - case 209 /* SwitchStatement */: - case 173 /* TaggedTemplateExpression */: - case 193 /* TemplateSpan */: - case 211 /* ThrowStatement */: - case 174 /* TypeAssertionExpression */: - case 179 /* TypeOfExpression */: - case 180 /* VoidExpression */: - case 201 /* WhileStatement */: - case 208 /* WithStatement */: - case 187 /* YieldExpression */: + case 168 /* ArrayLiteralExpression */: + case 193 /* AsExpression */: + case 185 /* BinaryExpression */: + case 172 /* CallExpression */: + case 245 /* CaseClause */: + case 138 /* ComputedPropertyName */: + case 186 /* ConditionalExpression */: + case 141 /* Decorator */: + case 179 /* DeleteExpression */: + case 201 /* DoStatement */: + case 171 /* ElementAccessExpression */: + case 231 /* ExportAssignment */: + case 199 /* ExpressionStatement */: + case 192 /* ExpressionWithTypeArguments */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 200 /* IfStatement */: + case 241 /* JsxClosingElement */: + case 238 /* JsxSelfClosingElement */: + case 239 /* JsxOpeningElement */: + case 243 /* JsxSpreadAttribute */: + case 244 /* JsxExpression */: + case 173 /* NewExpression */: + case 176 /* ParenthesizedExpression */: + case 184 /* PostfixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: + case 208 /* ReturnStatement */: + case 250 /* ShorthandPropertyAssignment */: + case 189 /* SpreadElementExpression */: + case 210 /* SwitchStatement */: + case 174 /* TaggedTemplateExpression */: + case 194 /* TemplateSpan */: + case 212 /* ThrowStatement */: + case 175 /* TypeAssertionExpression */: + case 180 /* TypeOfExpression */: + case 181 /* VoidExpression */: + case 202 /* WhileStatement */: + case 209 /* WithStatement */: + case 188 /* YieldExpression */: return true; - case 166 /* BindingElement */: - case 250 /* EnumMember */: - case 139 /* Parameter */: - case 248 /* PropertyAssignment */: - case 142 /* PropertyDeclaration */: - case 214 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 251 /* EnumMember */: + case 140 /* Parameter */: + case 249 /* PropertyAssignment */: + case 143 /* PropertyDeclaration */: + case 215 /* VariableDeclaration */: return parent.initializer === node; - case 169 /* PropertyAccessExpression */: + case 170 /* PropertyAccessExpression */: return parent.expression === node; - case 177 /* ArrowFunction */: - case 176 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 177 /* FunctionExpression */: return parent.body === node; - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return parent.left === node; } return false; } function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { - write("_arguments"); - return; - } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 251 /* SourceFile */) { + if (container.kind === 252 /* SourceFile */) { // Identifier references module export - if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + if (modulekind !== ts.ModuleKind.ES6 && modulekind !== ts.ModuleKind.System) { write("exports."); } } @@ -32736,20 +33545,20 @@ var ts; } } else { - if (modulekind !== 5 /* ES6 */) { + if (modulekind !== ts.ModuleKind.ES6) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 226 /* ImportClause */) { + if (declaration.kind === 227 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 229 /* ImportSpecifier */) { + else if (declaration.kind === 230 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_24 = declaration.propertyName || declaration.name; - var identifier = ts.getTextOfNodeFromSourceText(currentText, name_24); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getTextOfNodeFromSourceText(currentText, name_23); if (languageVersion === 0 /* ES3 */ && identifier === "default") { write("[\"default\"]"); } @@ -32761,13 +33570,26 @@ var ts; } } } - if (languageVersion !== 2 /* ES6 */) { - var declaration = resolver.getReferencedNestedRedeclaration(node); + if (languageVersion < 2 /* ES6 */) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration) { write(getGeneratedNameForNode(declaration.name)); return; } } + else if (resolver.getNodeCheckFlags(node) & 1048576 /* BodyScopedClassBinding */) { + // Due to the emit for class decorators, any reference to the class from inside of the class body + // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind + // behavior of class names in ES6. + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration) { + var classAlias = decoratedClassAliases[ts.getNodeId(declaration)]; + if (classAlias !== undefined) { + write(classAlias); + return; + } + } + } } if (ts.nodeIsSynthesized(node)) { write(node.text); @@ -32776,15 +33598,15 @@ var ts; writeTextOfNode(currentText, node); } } - function isNameOfNestedRedeclaration(node) { + function isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node) { if (languageVersion < 2 /* ES6 */) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 166 /* BindingElement */: - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 214 /* VariableDeclaration */: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_8 = node.parent; + switch (parent_8.kind) { + case 167 /* BindingElement */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 215 /* VariableDeclaration */: + return parent_8.name === node && resolver.isDeclarationWithCollidingName(parent_8); } } return false; @@ -32793,8 +33615,8 @@ var ts; if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { // in converted loop body arguments cannot be used directly. - var name_25 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); - write(name_25); + var name_24 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_24); return; } } @@ -32804,7 +33626,7 @@ var ts; else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } - else if (isNameOfNestedRedeclaration(node)) { + else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { write(getGeneratedNameForNode(node)); } else if (ts.nodeIsSynthesized(node)) { @@ -32894,10 +33716,10 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 184 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 185 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 185 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 186 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; @@ -32905,11 +33727,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 69 /* Identifier */: - case 167 /* ArrayLiteralExpression */: - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: - case 171 /* CallExpression */: - case 175 /* ParenthesizedExpression */: + case 168 /* ArrayLiteralExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 172 /* CallExpression */: + case 176 /* 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; @@ -32929,17 +33751,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 188 /* SpreadElementExpression */) { + if (e.kind === 189 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 167 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 168 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 188 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 189 /* SpreadElementExpression */) { i++; } write("["); @@ -32962,7 +33784,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 188 /* SpreadElementExpression */; + return node.kind === 189 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -32975,7 +33797,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 1024 /* MultiLine */) !== 0, + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ node.multiLine, /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } @@ -32994,7 +33816,7 @@ var ts; emitLinePreservingList(node, properties, /*allowTrailingComma*/ languageVersion >= 1 /* ES5 */, /*spacesBetweenBraces*/ true); } else { - var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; + var multiLine = node.multiLine; if (!multiLine) { write(" "); } @@ -33013,7 +33835,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; + var multiLine = node.multiLine; var properties = node.properties; write("("); if (multiLine) { @@ -33032,7 +33854,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 146 /* GetAccessor */ || property.kind === 147 /* SetAccessor */) { + if (property.kind === 147 /* GetAccessor */ || property.kind === 148 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -33084,13 +33906,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 248 /* PropertyAssignment */) { + if (property.kind === 249 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 249 /* ShorthandPropertyAssignment */) { + else if (property.kind === 250 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 144 /* MethodDeclaration */) { + else if (property.kind === 145 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -33124,7 +33946,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 === 137 /* ComputedPropertyName */) { + if (properties[i].name.kind === 138 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -33140,21 +33962,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(184 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(185 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(169 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(170 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(170 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(171 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -33162,7 +33984,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 === 174 /* TypeAssertionExpression */ || expr.kind === 192 /* AsExpression */) { + while (expr.kind === 175 /* TypeAssertionExpression */ || expr.kind === 193 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -33174,11 +33996,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 172 /* NewExpression */ && + expr.kind !== 173 /* NewExpression */ && expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(175 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(176 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -33213,7 +34035,7 @@ var ts; // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 251 /* SourceFile */; + return container && container.kind !== 252 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -33228,7 +34050,7 @@ var ts; // let obj = { y }; // } // Here we need to emit obj = { y : m.y } regardless of the output target. - if (modulekind !== 5 /* ES6 */ || isNamespaceExportReference(node.name)) { + if (modulekind !== ts.ModuleKind.ES6 || isNamespaceExportReference(node.name)) { // Emit identifier as an identifier write(": "); emit(node.name); @@ -33243,7 +34065,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 169 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 170 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -33254,7 +34076,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 169 /* PropertyAccessExpression */ || node.kind === 170 /* ElementAccessExpression */ + return node.kind === 170 /* PropertyAccessExpression */ || node.kind === 171 /* ElementAccessExpression */ ? resolver.getConstantValue(node) : undefined; } @@ -33281,6 +34103,14 @@ var ts; if (tryEmitConstantValue(node)) { return; } + if (languageVersion === 2 /* ES6 */ && + node.expression.kind === 95 /* SuperKeyword */ && + isInAsyncMethodWithSuperInES6(node)) { + var name_25 = ts.createSynthesizedNode(9 /* StringLiteral */); + name_25.text = node.name.text; + emitSuperAccessInAsyncMethod(node.expression, name_25); + return; + } emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal @@ -33343,7 +34173,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; default: @@ -33355,16 +34185,22 @@ var ts; if (tryEmitConstantValue(node)) { return; } + if (languageVersion === 2 /* ES6 */ && + node.expression.kind === 95 /* SuperKeyword */ && + isInAsyncMethodWithSuperInES6(node)) { + emitSuperAccessInAsyncMethod(node.expression, node.argumentExpression); + return; + } emit(node.expression); write("["); emit(node.argumentExpression); write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 188 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 189 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 175 /* ParenthesizedExpression */ || node.kind === 174 /* TypeAssertionExpression */ || node.kind === 192 /* AsExpression */) { + while (node.kind === 176 /* ParenthesizedExpression */ || node.kind === 175 /* TypeAssertionExpression */ || node.kind === 193 /* AsExpression */) { node = node.expression; } return node; @@ -33385,13 +34221,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 169 /* PropertyAccessExpression */) { + if (expr.kind === 170 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 170 /* ElementAccessExpression */) { + else if (expr.kind === 171 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -33424,23 +34260,42 @@ var ts; emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); } + function isInAsyncMethodWithSuperInES6(node) { + if (languageVersion === 2 /* ES6 */) { + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); + if (container && resolver.getNodeCheckFlags(container) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */)) { + return true; + } + } + return false; + } + function emitSuperAccessInAsyncMethod(superNode, argumentExpression) { + var container = ts.getSuperContainer(superNode, /*includeFunctions*/ false); + var isSuperBinding = resolver.getNodeCheckFlags(container) & 4096 /* AsyncMethodWithSuperBinding */; + write("_super("); + emit(argumentExpression); + write(isSuperBinding ? ").value" : ")"); + } function emitCallExpression(node) { if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { emitCallWithSpread(node); return; } + var expression = node.expression; var superCall = false; - if (node.expression.kind === 95 /* SuperKeyword */) { - emitSuper(node.expression); + var isAsyncMethodWithSuper = false; + if (expression.kind === 95 /* SuperKeyword */) { + emitSuper(expression); superCall = true; } else { - emit(node.expression); - superCall = node.expression.kind === 169 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; + superCall = ts.isSuperPropertyOrElementAccess(expression); + isAsyncMethodWithSuper = superCall && isInAsyncMethodWithSuperInES6(node); + emit(expression); } - if (superCall && languageVersion < 2 /* ES6 */) { + if (superCall && (languageVersion < 2 /* ES6 */ || isAsyncMethodWithSuper)) { write(".call("); - emitThis(node.expression); + emitThis(expression); if (node.arguments.length) { write(", "); emitCommaList(node.arguments); @@ -33505,12 +34360,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 !== 177 /* ArrowFunction */) { - if (node.expression.kind === 174 /* TypeAssertionExpression */ || node.expression.kind === 192 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 178 /* ArrowFunction */) { + if (node.expression.kind === 175 /* TypeAssertionExpression */ || node.expression.kind === 193 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 174 /* TypeAssertionExpression */ || operand.kind === 192 /* AsExpression */) { + while (operand.kind === 175 /* TypeAssertionExpression */ || operand.kind === 193 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -33521,15 +34376,15 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 182 /* PrefixUnaryExpression */ && - operand.kind !== 180 /* VoidExpression */ && - operand.kind !== 179 /* TypeOfExpression */ && - operand.kind !== 178 /* DeleteExpression */ && - operand.kind !== 183 /* PostfixUnaryExpression */ && - operand.kind !== 172 /* NewExpression */ && - !(operand.kind === 171 /* CallExpression */ && node.parent.kind === 172 /* NewExpression */) && - !(operand.kind === 176 /* FunctionExpression */ && node.parent.kind === 171 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 169 /* PropertyAccessExpression */)) { + if (operand.kind !== 183 /* PrefixUnaryExpression */ && + operand.kind !== 181 /* VoidExpression */ && + operand.kind !== 180 /* TypeOfExpression */ && + operand.kind !== 179 /* DeleteExpression */ && + operand.kind !== 184 /* PostfixUnaryExpression */ && + operand.kind !== 173 /* NewExpression */ && + !(operand.kind === 172 /* CallExpression */ && node.parent.kind === 173 /* NewExpression */) && + !(operand.kind === 177 /* FunctionExpression */ && node.parent.kind === 172 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 170 /* PropertyAccessExpression */)) { emit(operand); return; } @@ -33558,7 +34413,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 214 /* VariableDeclaration */ || node.parent.kind === 166 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 215 /* VariableDeclaration */ || node.parent.kind === 167 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -33589,7 +34444,7 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 182 /* PrefixUnaryExpression */) { + if (node.operand.kind === 183 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { write(" "); @@ -33643,12 +34498,12 @@ var ts; if (!node || !isCurrentFileSystemExternalModule()) { return false; } - var current = node; + var current = ts.getRootDeclaration(node).parent; while (current) { - if (current.kind === 251 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 2 /* Export */) !== 0); + if (current.kind === 252 /* SourceFile */) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 222 /* ModuleBlock */) { + else if (ts.isDeclaration(current)) { return false; } else { @@ -33663,12 +34518,12 @@ var ts; function emitExponentiationOperator(node) { var leftHandSideExpression = node.left; if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { - var synthesizedLHS; + var synthesizedLHS = void 0; var shouldEmitParentheses = false; if (ts.isElementAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(170 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + synthesizedLHS = ts.createSynthesizedNode(171 /* ElementAccessExpression */, /*startsOnNewLine*/ false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && @@ -33685,7 +34540,7 @@ var ts; else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(169 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + synthesizedLHS = ts.createSynthesizedNode(170 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; synthesizedLHS.dotToken = leftHandSideExpression.dotToken; @@ -33713,8 +34568,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && - (node.left.kind === 168 /* ObjectLiteralExpression */ || node.left.kind === 167 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 198 /* ExpressionStatement */); + (node.left.kind === 169 /* ObjectLiteralExpression */ || node.left.kind === 168 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 199 /* ExpressionStatement */); } else { var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && @@ -33779,7 +34634,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 195 /* Block */) { + if (node && node.kind === 196 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -33793,12 +34648,12 @@ var ts; } emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); - if (node.kind === 222 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 221 /* ModuleDeclaration */); + if (node.kind === 223 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 222 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 222 /* ModuleBlock */) { + if (node.kind === 223 /* ModuleBlock */) { emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); @@ -33806,7 +34661,7 @@ var ts; emitToken(16 /* CloseBraceToken */, node.statements.end); } function emitEmbeddedStatement(node) { - if (node.kind === 195 /* Block */) { + if (node.kind === 196 /* Block */) { write(" "); emit(node); } @@ -33818,7 +34673,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 177 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 178 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -33831,7 +34686,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(80 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 199 /* IfStatement */) { + if (node.elseStatement.kind === 200 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -33851,7 +34706,7 @@ var ts; else { emitNormalLoopBody(node, /*emitAsEmbeddedStatement*/ true); } - if (node.statement.kind === 195 /* Block */) { + if (node.statement.kind === 196 /* Block */) { write(" "); } else { @@ -33885,7 +34740,7 @@ var ts; // variables in variable declaration list were already hoisted return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576 /* BlockScoped */) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 3072 /* BlockScoped */) === 0) { // we are inside a converted loop - this can only happen in downlevel scenarios // record names for all variable declarations for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { @@ -33932,7 +34787,7 @@ var ts; } function shouldConvertLoopBody(node) { return languageVersion < 2 /* ES6 */ && - (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithBlockScopedBindingCapturedInFunction */) !== 0; + (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; } function emitLoop(node, loopEmitter) { var shouldConvert = shouldConvertLoopBody(node); @@ -33941,7 +34796,7 @@ var ts; } else { var loop = convertLoopBody(node); - if (node.parent.kind === 210 /* LabeledStatement */) { + if (node.parent.kind === 211 /* LabeledStatement */) { // if parent of the loop was labeled statement - attach the label to loop skipping converted loop body emitLabelAndColon(node.parent); } @@ -33952,35 +34807,31 @@ var ts; var functionName = makeUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 215 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 216 /* VariableDeclarationList */) { loopInitializer = node.initializer; } break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576 /* BlockScoped */)) { + var loopOutParameters; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3072 /* BlockScoped */)) { // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { var varDeclaration = _b[_a]; - collectNames(varDeclaration.name); + processVariableDeclaration(varDeclaration.name); } } - var bodyIsBlock = node.statement.kind === 195 /* Block */; + var bodyIsBlock = node.statement.kind === 196 /* Block */; var paramList = loopParameters ? loopParameters.join(", ") : ""; writeLine(); write("var " + functionName + " = function(" + paramList + ")"); - if (!bodyIsBlock) { - write(" {"); - writeLine(); - increaseIndent(); - } var convertedOuterLoopState = convertedLoopState; - convertedLoopState = {}; + convertedLoopState = { loopOutParameters: loopOutParameters }; if (convertedOuterLoopState) { // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. // if outer converted loop has already accumulated some state - pass it through @@ -34000,14 +34851,34 @@ var ts; convertedLoopState.hoistedLocalVariables = convertedOuterLoopState.hoistedLocalVariables; } } - emitEmbeddedStatement(node.statement); - if (!bodyIsBlock) { - decreaseIndent(); - writeLine(); - write("}"); - } - write(";"); + write(" {"); writeLine(); + increaseIndent(); + if (bodyIsBlock) { + emitLines(node.statement.statements); + } + else { + emit(node.statement); + } + writeLine(); + // end of loop body -> copy out parameter + copyLoopOutParameters(convertedLoopState, 1 /* ToOutParameter */, /*emitAsStatements*/ true); + decreaseIndent(); + writeLine(); + write("};"); + writeLine(); + if (loopOutParameters) { + // declare variables to hold out params for loop body + write("var "); + for (var i = 0; i < loopOutParameters.length; i++) { + if (i !== 0) { + write(", "); + } + write(loopOutParameters[i].outParamName); + } + write(";"); + writeLine(); + } if (convertedLoopState.argumentsName) { // if alias for arguments is set if (convertedOuterLoopState) { @@ -34044,7 +34915,7 @@ var ts; else { // deduplicate and hoist collected variable declarations write("var "); - var seen; + var seen = void 0; for (var _c = 0, _d = convertedLoopState.hoistedLocalVariables; _c < _d.length; _c++) { var id = _d[_c]; // Don't initialize seen unless we have at least one element. @@ -34067,15 +34938,21 @@ var ts; var currentLoopState = convertedLoopState; convertedLoopState = convertedOuterLoopState; return { functionName: functionName, paramList: paramList, state: currentLoopState }; - function collectNames(name) { + function processVariableDeclaration(name) { if (name.kind === 69 /* Identifier */) { - var nameText = isNameOfNestedRedeclaration(name) ? getGeneratedNameForNode(name) : name.text; + var nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(name) + ? getGeneratedNameForNode(name) + : name.text; loopParameters.push(nameText); + if (resolver.getNodeCheckFlags(name.parent) & 2097152 /* NeedsLoopOutParameter */) { + var reassignedVariable = { originalName: name, outParamName: makeUniqueName("out_" + nameText) }; + (loopOutParameters || (loopOutParameters = [])).push(reassignedVariable); + } } else { for (var _a = 0, _b = name.elements; _a < _b.length; _a++) { var element = _b[_a]; - collectNames(element.name); + processVariableDeclaration(element.name); } } } @@ -34091,7 +34968,7 @@ var ts; if (emitAsEmbeddedStatement) { emitEmbeddedStatement(node.statement); } - else if (node.statement.kind === 195 /* Block */) { + else if (node.statement.kind === 196 /* Block */) { emitLines(node.statement.statements); } else { @@ -34102,6 +34979,28 @@ var ts; convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } } + function copyLoopOutParameters(state, copyDirection, emitAsStatements) { + if (state.loopOutParameters) { + for (var _a = 0, _b = state.loopOutParameters; _a < _b.length; _a++) { + var outParam = _b[_a]; + if (copyDirection === 0 /* ToOriginal */) { + emitIdentifier(outParam.originalName); + write(" = " + outParam.outParamName); + } + else { + write(outParam.outParamName + " = "); + emitIdentifier(outParam.originalName); + } + if (emitAsStatements) { + write(";"); + writeLine(); + } + else { + write(", "); + } + } + } + } function emitConvertedLoopCall(loop, emitAsBlock) { if (emitAsBlock) { write(" {"); @@ -34118,6 +35017,8 @@ var ts; write("var " + loopResult + " = "); } write(loop.functionName + "(" + loop.paramList + ");"); + writeLine(); + copyLoopOutParameters(loop.state, 0 /* ToOriginal */, /*emitAsStatements*/ true); if (!isSimpleLoop) { // for non simple loops we need to store result returned from converted loop function and use it to do dispatching // converted loop function can return: @@ -34135,7 +35036,7 @@ var ts; } else { // top level converted loop - return unwrapped value - write("return " + loopResult + ".value"); + write("return " + loopResult + ".value;"); } writeLine(); } @@ -34201,7 +35102,7 @@ var ts; var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 216 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList); if (startIsEmitted) { @@ -34227,7 +35128,7 @@ var ts; } } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 204 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 205 /* ForOfStatement */) { emitLoop(node, emitDownLevelForOfStatementWorker); } else { @@ -34238,7 +35139,7 @@ var ts; var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList); @@ -34248,7 +35149,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 203 /* ForInStatement */) { + if (node.kind === 204 /* ForInStatement */) { write(" in "); } else { @@ -34338,7 +35239,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -34368,7 +35269,7 @@ var ts; // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 167 /* ArrayLiteralExpression */ || node.initializer.kind === 168 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 168 /* ArrayLiteralExpression */ || node.initializer.kind === 169 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); @@ -34396,23 +35297,26 @@ var ts; // it is possible if either // - break\continue is statement labeled and label is located inside the converted loop // - break\continue is non-labeled and located in non-converted loop\switch statement - var jump = node.kind === 206 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 207 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { + write("return "); + // explicit exit from loop -> copy out parameters + copyLoopOutParameters(convertedLoopState, 1 /* ToOutParameter */, /*emitAsStatements*/ false); if (!node.label) { - if (node.kind === 206 /* BreakStatement */) { + if (node.kind === 207 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; - write("return \"break\";"); + write("\"break\";"); } else { convertedLoopState.nonLocalJumps |= 4 /* Continue */; - write("return \"continue\";"); + write("\"continue\";"); } } else { - var labelMarker; - if (node.kind === 206 /* BreakStatement */) { + var labelMarker = void 0; + if (node.kind === 207 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -34420,12 +35324,12 @@ var ts; labelMarker = "continue-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); } - write("return \"" + labelMarker + "\";"); + write("\"" + labelMarker + "\";"); } return; } } - emitToken(node.kind === 206 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 207 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -34491,7 +35395,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap(currentLineMap, ts.skipTrivia(currentText, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 244 /* CaseClause */) { + if (node.kind === 245 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -34560,7 +35464,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 221 /* ModuleDeclaration */); + } while (node && node.kind !== 222 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -34569,13 +35473,13 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 2 /* Export */) { + if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); write("."); } - else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + else if (modulekind !== ts.ModuleKind.ES6 && modulekind !== ts.ModuleKind.System) { write("exports."); } } @@ -34585,15 +35489,15 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(180 /* VoidExpression */); + var result = ts.createSynthesizedNode(181 /* VoidExpression */); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 251 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 230 /* ExportAssignment */); + if (node.parent.kind === 252 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 231 /* ExportAssignment */); // only allow export default at a source file level - if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { + if (modulekind === ts.ModuleKind.CommonJS || modulekind === ts.ModuleKind.AMD || modulekind === ts.ModuleKind.UMD) { if (!isEs6Module) { if (languageVersion !== 0 /* ES3 */) { // default value of configurable, enumerable, writable are `false`. @@ -34609,11 +35513,11 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { writeLine(); emitStart(node); // emit call to exporter only for top level nodes - if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { + if (modulekind === ts.ModuleKind.System && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); @@ -34648,7 +35552,7 @@ var ts; } } function emitExportMemberAssignments(name) { - if (modulekind === 4 /* System */) { + if (modulekind === ts.ModuleKind.System) { return; } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { @@ -34667,7 +35571,7 @@ var ts; } } function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(modulekind === 4 /* System */); + ts.Debug.assert(modulekind === ts.ModuleKind.System); if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { return; } @@ -34697,7 +35601,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 214 /* VariableDeclaration */ || name.parent.kind === 166 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 215 /* VariableDeclaration */ || name.parent.kind === 167 /* BindingElement */); // If this is first var declaration, we need to start at var/let/const keyword instead // otherwise use nodeForSourceMap as the start position emitStart(isFirstVariableDeclaration(nodeForSourceMap) ? nodeForSourceMap.parent : nodeForSourceMap); @@ -34731,8 +35635,8 @@ var ts; return identifier; } function isFirstVariableDeclaration(root) { - return root.kind === 214 /* VariableDeclaration */ && - root.parent.kind === 215 /* VariableDeclarationList */ && + return root.kind === 215 /* VariableDeclaration */ && + root.parent.kind === 216 /* VariableDeclarationList */ && root.parent.declarations[0] === root; } function emitDestructuring(root, isAssignmentExpressionStatement, value) { @@ -34742,15 +35646,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 === 214 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 2 /* Export */; + if (root.kind === 215 /* VariableDeclaration */) { + var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 139 /* Parameter */) { + else if (root.kind === 140 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 184 /* BinaryExpression */) { + if (root.kind === 185 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -34785,14 +35689,14 @@ var ts; // If the temporary variable needs to be emitted use the source Map node for assignment of that statement value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(184 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(185 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(185 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(186 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -34807,7 +35711,7 @@ var ts; } function createPropertyAccessForDestructuringProperty(object, propName) { var index; - var nameIsComputed = propName.kind === 137 /* ComputedPropertyName */; + var nameIsComputed = propName.kind === 138 /* ComputedPropertyName */; if (nameIsComputed) { // TODO to handle when we look into sourcemaps for computed properties, for now use propName index = ensureIdentifier(propName.expression, /*reuseIdentifierExpressions*/ false, propName); @@ -34816,14 +35720,18 @@ var ts; // We create a synthetic copy of the identifier in order to avoid the rewriting that might // otherwise occur when the identifier is emitted. index = ts.createSynthesizedNode(propName.kind); - index.text = propName.text; + // We need to unescape identifier here because when parsing an identifier prefixing with "__" + // the parser need to append "_" in order to escape colliding with magic identifiers such as "__proto__" + // Therefore, in order to correctly emit identifiers that are written in original TypeScript file, + // we will unescapeIdentifier to remove additional underscore (if no underscore is added, the function will return original input string) + index.text = ts.unescapeIdentifier(propName.text); } return !nameIsComputed && index.kind === 69 /* Identifier */ ? createPropertyAccessExpression(object, index) : createElementAccessExpression(object, index); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(171 /* CallExpression */); + var call = ts.createSynthesizedNode(172 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -34836,15 +35744,15 @@ var ts; if (properties.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - // When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment + // When doing so we want to highlight the passed in source map node since thats the one needing this temp assignment value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode); } for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { var p = properties_5[_a]; - if (p.kind === 248 /* PropertyAssignment */ || p.kind === 249 /* ShorthandPropertyAssignment */) { + if (p.kind === 249 /* PropertyAssignment */ || p.kind === 250 /* ShorthandPropertyAssignment */) { var propName = p.name; - var target_1 = p.kind === 249 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; - // Assignment for target = value.propName should highligh whole property, hence use p as source map node + var target_1 = p.kind === 250 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + // Assignment for target = value.propName should highlight whole property, hence use p as source map node emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName), p); } } @@ -34854,14 +35762,14 @@ var ts; if (elements.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - // When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment + // When doing so we want to highlight the passed in source map node since thats the one needing this temp assignment value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 190 /* OmittedExpression */) { - // Assignment for target = value.propName should highligh whole property, hence use e as source map node - if (e.kind !== 188 /* SpreadElementExpression */) { + if (e.kind !== 191 /* OmittedExpression */) { + // Assignment for target = value.propName should highlight whole property, hence use e as source map node + if (e.kind !== 189 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)), e); } else if (i === elements.length - 1) { @@ -34872,20 +35780,20 @@ var ts; } function emitDestructuringAssignment(target, value, sourceMapNode) { // When emitting target = value use source map node to highlight, including any temporary assignments needed for this - if (target.kind === 249 /* ShorthandPropertyAssignment */) { + if (target.kind === 250 /* ShorthandPropertyAssignment */) { if (target.objectAssignmentInitializer) { value = createDefaultValueCheck(value, target.objectAssignmentInitializer, sourceMapNode); } target = target.name; } - else if (target.kind === 184 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + else if (target.kind === 185 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right, sourceMapNode); target = target.left; } - if (target.kind === 168 /* ObjectLiteralExpression */) { + if (target.kind === 169 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, sourceMapNode); } - else if (target.kind === 167 /* ArrayLiteralExpression */) { + else if (target.kind === 168 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value, sourceMapNode); } else { @@ -34907,7 +35815,7 @@ var ts; emitDestructuringAssignment(target, value, ts.nodeIsSynthesized(root) ? target : root); } else { - if (root.parent.kind !== 175 /* ParenthesizedExpression */) { + if (root.parent.kind !== 176 /* ParenthesizedExpression */) { write("("); } // Temporary assignment needed to emit root should highlight whole binary expression @@ -34916,7 +35824,7 @@ var ts; emitDestructuringAssignment(target, value, root); write(", "); emit(value); - if (root.parent.kind !== 175 /* ParenthesizedExpression */) { + if (root.parent.kind !== 176 /* ParenthesizedExpression */) { write(")"); } } @@ -34944,12 +35852,12 @@ var ts; } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 164 /* ObjectBindingPattern */) { + if (pattern.kind === 165 /* 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 !== 190 /* OmittedExpression */) { + else if (element.kind !== 191 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -34978,19 +35886,46 @@ var ts; } else { var initializer = node.initializer; - if (!initializer && languageVersion < 2 /* ES6 */) { - // downlevel emit for non-initialized let bindings defined in loops - // for (...) { let x; } - // should be - // for (...) { var = void 0; } - // this is necessary to preserve ES6 semantic in scenarios like - // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 8192 /* Let */); - // NOTE: default initialization should not be added to let bindings in for-in\for-of statements - if (isLetDefinedInLoop && - node.parent.parent.kind !== 203 /* ForInStatement */ && - node.parent.parent.kind !== 204 /* ForOfStatement */) { + if (!initializer && + languageVersion < 2 /* ES6 */ && + // for names - binding patterns that lack initializer there is no point to emit explicit initializer + // since downlevel codegen for destructuring will fail in the absence of initializer so all binding elements will say uninitialized + node.name.kind === 69 /* Identifier */) { + var container = ts.getEnclosingBlockScopeContainer(node); + var flags = resolver.getNodeCheckFlags(node); + // nested let bindings might need to be initialized explicitly to preserve ES6 semantic + // { let x = 1; } + // { let x; } // x here should be undefined. not 1 + // NOTES: + // Top level bindings never collide with anything and thus don't require explicit initialization. + // As for nested let bindings there are two cases: + // - nested let bindings that were not renamed definitely should be initialized explicitly + // { let x = 1; } + // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } + // Without explicit initialization code in /*1*/ can be executed even if some-condition is evaluated to false + // - renaming introduces fresh name that should not collide with any existing names, however renamed bindings sometimes also should be + // explicitly initialized. One particular case: non-captured binding declared inside loop body (but not in loop initializer) + // let x; + // for (;;) { + // let x; + // } + // in downlevel codegen inner 'x' will be renamed so it won't collide with outer 'x' however it will should be reset on every iteration + // as if it was declared anew. + // * Why non-captured binding - because if loop contains block scoped binding captured in some function then loop body will be rewritten + // to have a fresh scope on every iteration so everything will just work. + // * Why loop initializer is excluded - since we've introduced a fresh name it already will be undefined. + var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(container) || + (isCapturedInFunction && isDeclaredInLoop && container.kind === 196 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false)); + var emittedAsNestedLetDeclaration = ts.getCombinedNodeFlags(node) & 1024 /* Let */ && + !emittedAsTopLevel; + var emitExplicitInitializer = emittedAsNestedLetDeclaration && + container.kind !== 204 /* ForInStatement */ && + container.kind !== 205 /* ForOfStatement */ && + (!resolver.isDeclarationWithCollidingName(node) || + (isDeclaredInLoop && !isCapturedInFunction && !ts.isIterationStatement(container, /*lookInLabeledStatements*/ false))); + if (emitExplicitInitializer) { initializer = createVoidZero(); } } @@ -35008,7 +35943,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 190 /* OmittedExpression */) { + if (node.kind === 191 /* OmittedExpression */) { return; } var name = node.name; @@ -35019,20 +35954,14 @@ var ts; ts.forEach(name.elements, emitExportVariableAssignments); } } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 214 /* VariableDeclaration */ && node.parent.kind !== 166 /* BindingElement */)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } function isES6ExportedDeclaration(node) { - return !!(node.flags & 2 /* Export */) && - modulekind === 5 /* ES6 */ && - node.parent.kind === 251 /* SourceFile */; + return !!(node.flags & 1 /* Export */) && + modulekind === ts.ModuleKind.ES6 && + node.parent.kind === 252 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); @@ -35052,14 +35981,14 @@ var ts; write(";"); } } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } } function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { // If we're not exporting the variables, there's nothing special here. // Always emit comments for these nodes. - if (!(node.flags & 2 /* Export */)) { + if (!(node.flags & 1 /* Export */)) { return true; } // If we are exporting, but it's a top-level ES6 module exports, @@ -35100,7 +36029,7 @@ var ts; } function emitDefaultValueAssignments(node) { if (languageVersion < 2 /* ES6 */) { - var tempIndex = 0; + var tempIndex_1 = 0; ts.forEach(node.parameters, function (parameter) { // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. @@ -35117,15 +36046,15 @@ var ts; writeLine(); write("var "); if (hasBindingElements) { - emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex_1]); } else { - emit(tempParameters[tempIndex]); + emit(tempParameters[tempIndex_1]); write(" = "); emit(initializer); } write(";"); - tempIndex++; + tempIndex_1++; } } else if (initializer) { @@ -35189,12 +36118,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 146 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 147 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 177 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 178 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -35205,13 +36134,13 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 176 /* FunctionExpression */) { + if (node.kind === 177 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 216 /* FunctionDeclaration */) { + if (node.kind === 217 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) - return !!node.name || modulekind !== 5 /* ES6 */; + return !!node.name || modulekind !== ts.ModuleKind.ES6; } } function emitFunctionDeclaration(node) { @@ -35221,12 +36150,12 @@ var ts; // TODO (yuisu) : we should not have special cases to condition emitting comments // but have one place to fix check for these conditions. var kind = node.kind, parent = node.parent; - if (kind !== 144 /* MethodDeclaration */ && - kind !== 143 /* MethodSignature */ && + if (kind !== 145 /* MethodDeclaration */ && + kind !== 144 /* MethodSignature */ && parent && - parent.kind !== 248 /* PropertyAssignment */ && - parent.kind !== 171 /* CallExpression */ && - parent.kind !== 167 /* ArrayLiteralExpression */) { + parent.kind !== 249 /* PropertyAssignment */ && + parent.kind !== 172 /* CallExpression */ && + parent.kind !== 168 /* ArrayLiteralExpression */) { // 1. Methods will emit comments at their assignment declaration sites. // // 2. If the function is a property of object literal, emitting leading-comments @@ -35265,11 +36194,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (modulekind !== 5 /* ES6 */ && kind === 216 /* FunctionDeclaration */ && parent === currentSourceFile && node.name) { + if (modulekind !== ts.ModuleKind.ES6 && kind === 217 /* FunctionDeclaration */ && parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (kind !== 144 /* MethodDeclaration */ && kind !== 143 /* MethodSignature */) { + if (kind !== 145 /* MethodDeclaration */ && kind !== 144 /* MethodSignature */) { emitTrailingComments(node); } } @@ -35302,8 +36231,8 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 177 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; + var isArrowFunction = node.kind === 178 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -35381,6 +36310,14 @@ var ts; write(" {"); increaseIndent(); writeLine(); + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + writeLines("\nconst _super = (function (geti, seti) {\n const cache = Object.create(null);\n return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });\n})(name => super[name], (name, value) => super[name] = value);"); + writeLine(); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + write("const _super = name => super[name];"); + writeLine(); + } write("return"); } write(" __awaiter(this"); @@ -35390,19 +36327,14 @@ var ts; else { write(", void 0, "); } - if (promiseConstructor) { + if (languageVersion >= 2 /* ES6 */ || !promiseConstructor) { + write("void 0"); + } + else { emitEntityNameAsExpression(promiseConstructor, /*useFallback*/ false); } - else { - write("Promise"); - } // Emit the call to __awaiter. - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } + write(", function* ()"); // Emit the signature and body for the inner generator function. emitFunctionBody(node); write(")"); @@ -35421,7 +36353,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 195 /* Block */) { + if (node.body.kind === 196 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -35480,10 +36412,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 174 /* TypeAssertionExpression */) { + while (current.kind === 175 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 168 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 169 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -35554,23 +36486,27 @@ var ts; } emitToken(16 /* CloseBraceToken */, body.statements.end); } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 198 /* ExpressionStatement */) { - var expr = statement.expression; - if (expr && expr.kind === 171 /* CallExpression */) { - var func = expr.expression; - if (func && func.kind === 95 /* SuperKeyword */) { - return statement; - } - } - } + /** + * Return the statement at a given index if it is a super-call statement + * @param ctor a constructor declaration + * @param index an index to constructor's body to check + */ + function getSuperCallAtGivenIndex(ctor, index) { + if (!ctor.body) { + return undefined; + } + var statements = ctor.body.statements; + if (!statements || index >= statements.length) { + return undefined; + } + var statement = statements[index]; + if (statement.kind === 199 /* ExpressionStatement */) { + return ts.isSuperCallExpression(statement.expression) ? statement : undefined; } } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 56 /* AccessibilityModifier */) { + if (param.flags & 28 /* AccessibilityModifier */) { writeLine(); emitStart(param); emitStart(param.name); @@ -35593,7 +36529,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 137 /* ComputedPropertyName */) { + else if (memberName.kind === 138 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -35605,7 +36541,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 142 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { + if (member.kind === 143 /* PropertyDeclaration */ && isStatic === ((member.flags & 32 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -35626,7 +36562,7 @@ var ts; emit(receiver); } else { - if (property.flags & 64 /* Static */) { + if (property.flags & 32 /* Static */) { emitDeclarationName(node); } else { @@ -35645,11 +36581,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 194 /* SemicolonClassElement */) { + if (member.kind === 195 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) { + else if (member.kind === 145 /* MethodDeclaration */ || node.kind === 144 /* MethodSignature */) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -35666,7 +36602,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 146 /* GetAccessor */ || member.kind === 147 /* SetAccessor */) { + else if (member.kind === 147 /* GetAccessor */ || member.kind === 148 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -35716,22 +36652,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) && !member.body) { + if ((member.kind === 145 /* MethodDeclaration */ || node.kind === 144 /* MethodSignature */) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 144 /* MethodDeclaration */ || - member.kind === 146 /* GetAccessor */ || - member.kind === 147 /* SetAccessor */) { + else if (member.kind === 145 /* MethodDeclaration */ || + member.kind === 147 /* GetAccessor */ || + member.kind === 148 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 64 /* Static */) { + if (member.flags & 32 /* Static */) { write("static "); } - if (member.kind === 146 /* GetAccessor */) { + if (member.kind === 147 /* GetAccessor */) { write("get "); } - else if (member.kind === 147 /* SetAccessor */) { + else if (member.kind === 148 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -35742,7 +36678,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 194 /* SemicolonClassElement */) { + else if (member.kind === 195 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -35771,11 +36707,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 145 /* Constructor */ && !member.body) { + if (member.kind === 146 /* Constructor */ && !member.body) { emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 142 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { + if (member.kind === 143 /* PropertyDeclaration */ && member.initializer && (member.flags & 32 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -35829,7 +36765,7 @@ var ts; emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); + superCall = getSuperCallAtGivenIndex(ctor, startIndex); if (superCall) { writeLine(); emit(superCall); @@ -35883,68 +36819,108 @@ var ts; else { emitClassLikeDeclarationForES6AndHigher(node); } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } } function emitClassLikeDeclarationForES6AndHigher(node) { + var decoratedClassAlias; var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* 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: + // When we emit an ES6 class that has a class decorator, we must tailor the + // emit to certain specific cases. // - // * For a local class declaration: + // In the simplest case, we emit the class declaration as a let declaration, and + // evaluate decorators after the close of the class body: // - // @dec class C { - // } + // TypeScript | Javascript + // --------------------------------|------------------------------------ + // @dec | let C = class C { + // class C { | } + // } | C = __decorate([dec], C); + // --------------------------------|------------------------------------ + // @dec | export let C = class C { + // export class C { | } + // } | C = __decorate([dec], C); + // --------------------------------------------------------------------- + // [Example 1] // - // The emit should be: + // If a class declaration contains a reference to itself *inside* of the class body, + // this introduces two bindings to the class: One outside of the class body, and one + // inside of the class body. If we apply decorators as in [Example 1] above, there + // is the possibility that the decorator `dec` will return a new value for the + // constructor, which would result in the binding inside of the class no longer + // pointing to the same reference as the binding outside of the class. // - // let C = class { - // }; - // C = __decorate([dec], C); + // As a result, we must instead rewrite all references to the class *inside* of the + // class body to instead point to a local temporary alias for the class: // - // * For an exported class declaration: + // TypeScript | Javascript + // --------------------------------|------------------------------------ + // @dec | let C_1; + // class C { | let C = C_1 = class C { + // static x() { return C.y; } | static x() { return C_1.y; } + // static y = 1; | } + // } | C.y = 1; + // | C = C_1 = __decorate([dec], C); + // --------------------------------|------------------------------------ + // @dec | let C_1; + // export class C { | export let C = C_1 = class C { + // static x() { return C.y; } | static x() { return C_1.y; } + // static y = 1; | } + // } | C.y = 1; + // | C = C_1 = __decorate([dec], C); + // --------------------------------------------------------------------- + // [Example 2] // - // @dec export class C { - // } + // If a class declaration is the default export of a module, we instead emit + // the export after the decorated declaration: // - // The emit should be: + // TypeScript | Javascript + // --------------------------------|------------------------------------ + // @dec | let default_1 = class { + // export default class { | } + // } | default_1 = __decorate([dec], default_1); + // | export default default_1; + // --------------------------------|------------------------------------ + // @dec | let C = class C { + // export default class { | } + // } | C = __decorate([dec], C); + // | export default C; + // --------------------------------------------------------------------- + // [Example 3] // - // export let C = class { - // }; - // C = __decorate([dec], C); + // If the class declaration is the default export and a reference to itself + // inside of the class body, we must emit both an alias for the class *and* + // move the export after the declaration: // - // * For a default export of a class declaration with a name: - // - // @dec default export class C { - // } - // - // The emit should be: - // - // let C = class { - // } - // C = __decorate([dec], C); - // export default C; - // - // * For a default export of a class declaration without a name: - // - // @dec default export class { - // } - // - // The emit should be: - // - // let _default = class { - // } - // _default = __decorate([dec], _default); - // export default _default; + // TypeScript | Javascript + // --------------------------------|------------------------------------ + // @dec | let C_1; + // export default class C { | let C = C_1 = class C { + // static x() { return C.y; } | static x() { return C_1.y; } + // static y = 1; | } + // } | C.y = 1; + // | C = C_1 = __decorate([dec], C); + // | export default C; + // --------------------------------------------------------------------- + // [Example 4] // + if (resolver.getNodeCheckFlags(node) & 524288 /* ClassWithBodyScopedClassBinding */) { + decoratedClassAlias = ts.unescapeIdentifier(makeUniqueName(node.name ? node.name.text : "default")); + decoratedClassAliases[ts.getNodeId(node)] = decoratedClassAlias; + write("let " + decoratedClassAlias + ";"); + writeLine(); + } if (isES6ExportedDeclaration(node) && !(node.flags & 512 /* Default */)) { write("export "); } write("let "); emitDeclarationName(node); + if (decoratedClassAlias !== undefined) { + write(" = " + decoratedClassAlias); + } write(" = "); } else if (isES6ExportedDeclaration(node)) { @@ -35966,7 +36942,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, /*isStatic*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 189 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 190 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -35979,7 +36955,7 @@ var ts; // emit name if // - node has a name // - this is default export with static initializers - if ((node.name || (node.flags & 512 /* Default */ && (staticProperties.length > 0 || modulekind !== 5 /* ES6 */))) && !thisNodeIsDecorated) { + if (node.name || (node.flags & 512 /* Default */ && (staticProperties.length > 0 || modulekind !== ts.ModuleKind.ES6) && !thisNodeIsDecorated)) { write(" "); emitDeclarationName(node); } @@ -35996,15 +36972,8 @@ var ts; decreaseIndent(); writeLine(); emitToken(16 /* CloseBraceToken */, node.members.end); - // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. - // For a decorated class, we need to assign its name (if it has one). This is because we emit - // the class as a class expression to avoid the double-binding of the identifier: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // if (thisNodeIsDecorated) { + decoratedClassAliases[ts.getNodeId(node)] = undefined; write(";"); } // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -36028,12 +36997,12 @@ var ts; else { writeLine(); emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); + emitDecoratorsOfClass(node, decoratedClassAlias); } - if (!(node.flags & 2 /* Export */)) { + if (!(node.flags & 1 /* Export */)) { return; } - if (modulekind !== 5 /* ES6 */) { + if (modulekind !== ts.ModuleKind.ES6) { emitExportMemberAssignment(node); } else { @@ -36048,7 +37017,7 @@ var ts; write(";"); } } - else if (node.parent.kind !== 251 /* SourceFile */) { + else if (node.parent.kind !== 252 /* SourceFile */) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -36060,7 +37029,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -36098,7 +37067,7 @@ var ts; emitMemberFunctionsForES5AndLower(node); emitPropertyDeclarations(node, getInitializedProperties(node, /*isStatic*/ true)); writeLine(); - emitDecoratorsOfClass(node); + emitDecoratorsOfClass(node, /*decoratedClassAlias*/ undefined); writeLine(); emitToken(16 /* CloseBraceToken */, node.members.end, function () { write("return "); @@ -36121,26 +37090,26 @@ var ts; emit(baseTypeNode.expression); } write("))"); - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { emitExportMemberAssignment(node); } } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 64 /* Static */)) { + if (!(member.flags & 32 /* Static */)) { write(".prototype"); } } - function emitDecoratorsOfClass(node) { + function emitDecoratorsOfClass(node, decoratedClassAlias) { emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 64 /* Static */); - emitDecoratorsOfConstructor(node); + emitDecoratorsOfMembers(node, 32 /* Static */); + emitDecoratorsOfConstructor(node, decoratedClassAlias); } - function emitDecoratorsOfConstructor(node) { + function emitDecoratorsOfConstructor(node, decoratedClassAlias) { var decorators = node.decorators; var constructor = ts.getFirstConstructorWithBody(node); var firstParameterDecorator = constructor && ts.forEach(constructor.parameters, function (parameter) { return parameter.decorators; }); @@ -36161,6 +37130,9 @@ var ts; writeLine(); emitStart(node.decorators || firstParameterDecorator); emitDeclarationName(node); + if (decoratedClassAlias !== undefined) { + write(" = " + decoratedClassAlias); + } write(" = __decorate(["); increaseIndent(); writeLine(); @@ -36183,7 +37155,7 @@ var ts; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; // only emit members in the correct group - if ((member.flags & 64 /* Static */) !== staticFlag) { + if ((member.flags & 32 /* Static */) !== staticFlag) { continue; } // skip members that cannot be decorated (such as the constructor) @@ -36209,7 +37181,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 144 /* MethodDeclaration */) { + if (member.kind === 145 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -36266,7 +37238,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); if (languageVersion > 0 /* ES3 */) { - if (member.kind !== 142 /* PropertyDeclaration */) { + if (member.kind !== 143 /* PropertyDeclaration */) { // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. // We have this extra argument here so that we can inject an explicit property descriptor at a later date. write(", null"); @@ -36286,19 +37258,19 @@ var ts; function emitDecoratorsOfParameters(node, leadingComma) { var argumentsWritten = 0; if (node) { - var parameterIndex = 0; + var parameterIndex_1 = 0; for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { var parameter = _b[_a]; if (ts.nodeIsDecorated(parameter)) { var decorators = parameter.decorators; argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { - write("__param(" + parameterIndex + ", "); + write("__param(" + parameterIndex_1 + ", "); emit(decorator.expression); write(")"); }); leadingComma = true; } - parameterIndex++; + parameterIndex_1++; } } return argumentsWritten; @@ -36308,10 +37280,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 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 142 /* PropertyDeclaration */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 143 /* PropertyDeclaration */: return true; } return false; @@ -36321,7 +37293,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 144 /* MethodDeclaration */: + case 145 /* MethodDeclaration */: return true; } return false; @@ -36331,9 +37303,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 217 /* ClassDeclaration */: - case 144 /* MethodDeclaration */: - case 147 /* SetAccessor */: + case 218 /* ClassDeclaration */: + case 145 /* MethodDeclaration */: + case 148 /* SetAccessor */: return true; } return false; @@ -36351,19 +37323,19 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: write("Function"); return; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 139 /* Parameter */: + case 140 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 146 /* GetAccessor */: + case 147 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 147 /* SetAccessor */: + case 148 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -36379,40 +37351,40 @@ var ts; case 103 /* VoidKeyword */: write("void 0"); return; - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: write("Function"); return; - case 157 /* ArrayType */: - case 158 /* TupleType */: + case 158 /* ArrayType */: + case 159 /* TupleType */: write("Array"); return; - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: case 120 /* BooleanKeyword */: write("Boolean"); return; - case 130 /* StringKeyword */: - case 163 /* StringLiteralType */: + case 131 /* StringKeyword */: + case 164 /* StringLiteralType */: write("String"); return; - case 128 /* NumberKeyword */: + case 129 /* NumberKeyword */: write("Number"); return; - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: write("Symbol"); return; - case 152 /* TypeReference */: + case 153 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 155 /* TypeQuery */: - case 156 /* TypeLiteral */: - case 159 /* UnionType */: - case 160 /* IntersectionType */: + case 156 /* TypeQuery */: + case 157 /* TypeLiteral */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: case 117 /* AnyKeyword */: - case 162 /* ThisType */: + case 163 /* ThisType */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -36484,8 +37456,8 @@ var ts; // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { - var valueDeclaration; - if (node.kind === 217 /* ClassDeclaration */) { + var valueDeclaration = void 0; + if (node.kind === 218 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -36501,10 +37473,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 157 /* ArrayType */) { + if (parameterType.kind === 158 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 152 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 153 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -36581,7 +37553,7 @@ var ts; if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted var isES6ExportedEnum = isES6ExportedDeclaration(node); - if (!(node.flags & 2 /* Export */) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220 /* EnumDeclaration */))) { + if (!(node.flags & 1 /* Export */) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221 /* EnumDeclaration */))) { emitStart(node); if (isES6ExportedEnum) { write("export "); @@ -36610,7 +37582,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 2 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted writeLine(); emitStart(node); @@ -36621,8 +37593,8 @@ var ts; emitEnd(node); write(";"); } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile) { + if (modulekind === ts.ModuleKind.System && (node.flags & 1 /* Export */)) { // write the call to exporter for enum writeLine(); write(exportFunctionForFile + "(\""); @@ -36663,7 +37635,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 221 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 222 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -36687,7 +37659,7 @@ var ts; var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { var isES6ExportedNamespace = isES6ExportedDeclaration(node); - if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221 /* ModuleDeclaration */)) { + if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 222 /* ModuleDeclaration */)) { emitStart(node); if (isES6ExportedNamespace) { write("export "); @@ -36705,7 +37677,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 222 /* ModuleBlock */) { + if (node.body.kind === 223 /* ModuleBlock */) { var saveConvertedLoopState = convertedLoopState; var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -36731,7 +37703,7 @@ var ts; } write(")("); // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 2 /* Export */) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -36741,7 +37713,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { + if (modulekind === ts.ModuleKind.System && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -36781,16 +37753,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 224 /* ImportEqualsDeclaration */) { + if (node.kind === 225 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 228 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 225 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 226 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -36799,7 +37771,7 @@ var ts; ts.forEachChild(node, emitExportImportAssignments); } function emitImportDeclaration(node) { - if (modulekind !== 5 /* ES6 */) { + if (modulekind !== ts.ModuleKind.ES6) { return emitExternalImportDeclaration(node); } // ES6 import @@ -36818,7 +37790,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 228 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -36844,16 +37816,19 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 224 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; + var isExportedImport = node.kind === 225 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (modulekind !== 2 /* AMD */) { + var varOrConst = (languageVersion <= 1 /* ES5 */) ? "var " : "const "; + if (modulekind !== ts.ModuleKind.AMD) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { // import x = require("foo") // import * as x from "foo" - if (!isExportedImport) - write("var "); + if (!isExportedImport) { + write(varOrConst); + } + ; emitModuleMemberName(namespaceDeclaration); write(" = "); } @@ -36863,9 +37838,9 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 225 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 226 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { - write("var "); + write(varOrConst); write(getGeneratedNameForNode(node)); write(" = "); } @@ -36892,7 +37867,7 @@ var ts; } else if (namespaceDeclaration && isDefaultImport(node)) { // import d, * as x from "foo" - write("var "); + write(varOrConst); emitModuleMemberName(namespaceDeclaration); write(" = "); write(getGeneratedNameForNode(node)); @@ -36926,7 +37901,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 2 /* Export */)) { + else if (!(node.flags & 1 /* Export */)) { write("var "); } } @@ -36948,14 +37923,14 @@ var ts; } } function emitExportDeclaration(node) { - ts.Debug.assert(modulekind !== 4 /* System */); - if (modulekind !== 5 /* ES6 */) { + ts.Debug.assert(modulekind !== ts.ModuleKind.System); + if (modulekind !== ts.ModuleKind.ES6) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); var generatedName = getGeneratedNameForNode(node); if (node.exportClause) { // export { x, y, ... } from "foo" - if (modulekind !== 2 /* AMD */) { + if (modulekind !== ts.ModuleKind.AMD) { write("var "); write(generatedName); write(" = "); @@ -36984,7 +37959,7 @@ var ts; if (hasExportStarsToExportValues && resolver.moduleExportsSomeValue(node.moduleSpecifier)) { writeLine(); write("__export("); - if (modulekind !== 2 /* AMD */) { + if (modulekind !== ts.ModuleKind.AMD) { emitRequire(ts.getExternalModuleName(node)); } else { @@ -37017,7 +37992,7 @@ var ts; } } function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(modulekind === 5 /* ES6 */); + ts.Debug.assert(modulekind === ts.ModuleKind.ES6); var needsComma = false; for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { var specifier = specifiers_1[_a]; @@ -37036,14 +38011,14 @@ var ts; } function emitExportAssignment(node) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (modulekind === 5 /* ES6 */) { + if (modulekind === ts.ModuleKind.ES6) { writeLine(); emitStart(node); write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 216 /* FunctionDeclaration */ && - expression.kind !== 217 /* ClassDeclaration */) { + if (expression.kind !== 217 /* FunctionDeclaration */ && + expression.kind !== 218 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -37051,7 +38026,7 @@ var ts; else { writeLine(); emitStart(node); - if (modulekind === 4 /* System */) { + if (modulekind === ts.ModuleKind.System) { write(exportFunctionForFile + "(\"default\","); emit(node.expression); write(")"); @@ -37080,7 +38055,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" @@ -37090,13 +38065,13 @@ var ts; externalImports.push(node); } break; - case 224 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 235 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 225 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 236 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -37119,7 +38094,7 @@ var ts; } } break; - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -37145,10 +38120,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name); } - if (node.kind === 225 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 226 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 231 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 232 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -37174,8 +38149,8 @@ var ts; for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { var importNode = externalImports_1[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 231 /* ExportDeclaration */ || - (importNode.kind === 225 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 232 /* ExportDeclaration */ || + (importNode.kind === 226 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -37196,7 +38171,7 @@ var ts; // when resolving exports local exported entries/indirect exported entries in the module // should always win over entries with similar names that were added via star exports // to support this we store names of local/indirect exported entries in a set. - // this set is used to filter names brought by star expors. + // this set is used to filter names brought by star exports. if (!hasExportStarsToExportValues) { // local names set is needed only in presence of star exports return undefined; @@ -37208,7 +38183,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { var externalImport = externalImports_2[_a]; - if (externalImport.kind === 231 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 232 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -37240,7 +38215,7 @@ var ts; } for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { var externalImport = externalImports_3[_d]; - if (externalImport.kind !== 231 /* ExportDeclaration */) { + if (externalImport.kind !== 232 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -37344,14 +38319,14 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 217 /* ClassDeclaration */ || local.kind === 221 /* ModuleDeclaration */ || local.kind === 220 /* EnumDeclaration */) { + if (local.kind === 218 /* ClassDeclaration */ || local.kind === 222 /* ModuleDeclaration */ || local.kind === 221 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); - if (flags & 2 /* Export */) { + if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -37365,7 +38340,7 @@ var ts; var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 2 /* Export */) { + if (f.flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -37375,24 +38350,24 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 4 /* Ambient */) { + if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 216 /* FunctionDeclaration */) { + if (node.kind === 217 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 220 /* EnumDeclaration */) { + if (node.kind === 221 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -37401,7 +38376,7 @@ var ts; } return; } - if (node.kind === 221 /* ModuleDeclaration */) { + if (node.kind === 222 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -37410,7 +38385,7 @@ var ts; } return; } - if (node.kind === 214 /* VariableDeclaration */ || node.kind === 166 /* BindingElement */) { + if (node.kind === 215 /* VariableDeclaration */ || node.kind === 167 /* BindingElement */) { if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_30 = node.name; if (name_30.kind === 69 /* Identifier */) { @@ -37450,11 +38425,11 @@ var ts; // - it is top level block scoped // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 251 /* SourceFile */; + return (ts.getCombinedNodeFlags(node) & 3072 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 252 /* SourceFile */; } function isCurrentFileSystemExternalModule() { - return modulekind === 4 /* System */ && isCurrentFileExternalModule; + return modulekind === ts.ModuleKind.System && isCurrentFileExternalModule; } function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: @@ -37526,21 +38501,21 @@ var ts; var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -37599,10 +38574,10 @@ var ts; // - import declarations are not emitted since they are already handled in setters // - export declarations with module specifiers are not emitted since they were already written in setters // - export declarations without module specifiers are emitted preserving the order - case 216 /* FunctionDeclaration */: - case 225 /* ImportDeclaration */: + case 217 /* FunctionDeclaration */: + case 226 /* ImportDeclaration */: continue; - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -37611,7 +38586,7 @@ var ts; } } continue; - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { // - import equals declarations that import external modules are not emitted continue; @@ -37645,6 +38620,7 @@ var ts; ts.Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); + contextObjectForFile = makeUniqueName("context"); writeLine(); write("System.register("); writeModuleName(node, emitRelativePathAsModuleName); @@ -37653,14 +38629,20 @@ var ts; var dependencyGroups = []; for (var i = 0; i < externalImports.length; i++) { var text = getExternalModuleNameText(externalImports[i], emitRelativePathAsModuleName); - if (ts.hasProperty(groupIndices, text)) { + if (text === undefined) { + continue; + } + // text should be quoted string + // for deduplication purposes in key remove leading and trailing quotes so 'a' and "a" will be considered the same + var key = text.substr(1, text.length - 2); + if (ts.hasProperty(groupIndices, key)) { // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; + var groupIndex = groupIndices[key]; dependencyGroups[groupIndex].push(externalImports[i]); continue; } else { - groupIndices[text] = dependencyGroups.length; + groupIndices[key] = dependencyGroups.length; dependencyGroups.push([externalImports[i]]); } if (i !== 0) { @@ -37668,10 +38650,13 @@ var ts; } write(text); } - write("], function(" + exportFunctionForFile + ") {"); + write("], function(" + exportFunctionForFile + ", " + contextObjectForFile + ") {"); writeLine(); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); + writeLine(); + write("var __moduleName = " + contextObjectForFile + " && " + contextObjectForFile + ".id;"); + writeLine(); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -37761,7 +38746,7 @@ var ts; writeModuleName(node, emitRelativePathAsModuleName); emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -37772,7 +38757,7 @@ var ts; write("});"); } function emitCommonJSModule(node) { - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ true); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -37792,7 +38777,7 @@ var ts; writeLines(" }\n})("); emitAMDFactoryHeader(dependencyNames); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -37880,6 +38865,18 @@ var ts; } return result; } + function isJsxChildEmittable(child) { + if (child.kind === 244 /* JsxExpression */) { + // Don't emit empty expressions + return !!child.expression; + } + else if (child.kind === 240 /* JsxText */) { + // Don't emit empty strings + return !!getTextToEmit(child); + } + return true; + } + ; function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2 /* React */: @@ -37970,22 +38967,22 @@ var ts; if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 4194304 /* HasClassExtends */)) { + if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 262144 /* HasClassExtends */)) { writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && node.flags & 8388608 /* HasDecorators */) { + if (!decorateEmitted && node.flags & 524288 /* HasDecorators */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && node.flags & 16777216 /* HasParamDecorators */) { + if (!paramEmitted && node.flags & 1048576 /* HasParamDecorators */) { writeLines(paramHelper); paramEmitted = true; } - if (!awaiterEmitted && node.flags & 33554432 /* HasAsyncFunctions */) { + if (!awaiterEmitted && node.flags & 2097152 /* HasAsyncFunctions */) { writeLines(awaiterHelper); awaiterEmitted = true; } @@ -37998,7 +38995,7 @@ var ts; emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (isOwnFileEmit || (!ts.isExternalModule(node) && compilerOptions.isolatedModules)) { - var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ts.ModuleKind.CommonJS]; emitModule(node); } else { @@ -38027,7 +39024,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 4 /* Ambient */) { + if (node.flags & 2 /* Ambient */) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -38073,24 +39070,24 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: - case 225 /* ImportDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 230 /* ExportAssignment */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: + case 226 /* ImportDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 231 /* ExportAssignment */: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -38102,9 +39099,9 @@ var ts; // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 195 /* Block */ && + if (node.kind !== 196 /* Block */ && node.parent && - node.parent.kind === 177 /* ArrowFunction */ && + node.parent.kind === 178 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -38117,13 +39114,13 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return emitIdentifier(node); - case 139 /* Parameter */: + case 140 /* Parameter */: return emitParameter(node); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return emitMethod(node); - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return emitAccessor(node); case 97 /* ThisKeyword */: return emitThis(node); @@ -38143,142 +39140,142 @@ var ts; case 13 /* TemplateMiddle */: case 14 /* TemplateTail */: return emitLiteral(node); - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: return emitTemplateExpression(node); - case 193 /* TemplateSpan */: + case 194 /* TemplateSpan */: return emitTemplateSpan(node); - case 236 /* JsxElement */: - case 237 /* JsxSelfClosingElement */: + case 237 /* JsxElement */: + case 238 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 239 /* JsxText */: + case 240 /* JsxText */: return emitJsxText(node); - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: return emitJsxExpression(node); - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return emitQualifiedName(node); - case 164 /* ObjectBindingPattern */: + case 165 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 165 /* ArrayBindingPattern */: + case 166 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 166 /* BindingElement */: + case 167 /* BindingElement */: return emitBindingElement(node); - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 248 /* PropertyAssignment */: + case 249 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 249 /* ShorthandPropertyAssignment */: + case 250 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 169 /* PropertyAccessExpression */: + case 170 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 170 /* ElementAccessExpression */: + case 171 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 171 /* CallExpression */: + case 172 /* CallExpression */: return emitCallExpression(node); - case 172 /* NewExpression */: + case 173 /* NewExpression */: return emitNewExpression(node); - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 174 /* TypeAssertionExpression */: + case 175 /* TypeAssertionExpression */: return emit(node.expression); - case 192 /* AsExpression */: + case 193 /* AsExpression */: return emit(node.expression); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return emitParenExpression(node); - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 178 /* DeleteExpression */: + case 179 /* DeleteExpression */: return emitDeleteExpression(node); - case 179 /* TypeOfExpression */: + case 180 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 180 /* VoidExpression */: + case 181 /* VoidExpression */: return emitVoidExpression(node); - case 181 /* AwaitExpression */: + case 182 /* AwaitExpression */: return emitAwaitExpression(node); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 183 /* PostfixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return emitBinaryExpression(node); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return emitConditionalExpression(node); - case 188 /* SpreadElementExpression */: + case 189 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: return emitYieldExpression(node); - case 190 /* OmittedExpression */: + case 191 /* OmittedExpression */: return; - case 195 /* Block */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return emitBlock(node); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return emitVariableStatement(node); - case 197 /* EmptyStatement */: + case 198 /* EmptyStatement */: return write(";"); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: return emitExpressionStatement(node); - case 199 /* IfStatement */: + case 200 /* IfStatement */: return emitIfStatement(node); - case 200 /* DoStatement */: + case 201 /* DoStatement */: return emitDoStatement(node); - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: return emitWhileStatement(node); - case 202 /* ForStatement */: + case 203 /* ForStatement */: return emitForStatement(node); - case 204 /* ForOfStatement */: - case 203 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 204 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 205 /* ContinueStatement */: - case 206 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 207 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: return emitReturnStatement(node); - case 208 /* WithStatement */: + case 209 /* WithStatement */: return emitWithStatement(node); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: return emitSwitchStatement(node); - case 244 /* CaseClause */: - case 245 /* DefaultClause */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return emitLabeledStatement(node); - case 211 /* ThrowStatement */: + case 212 /* ThrowStatement */: return emitThrowStatement(node); - case 212 /* TryStatement */: + case 213 /* TryStatement */: return emitTryStatement(node); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return emitCatchClause(node); - case 213 /* DebuggerStatement */: + case 214 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 214 /* VariableDeclaration */: + case 215 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: return emitClassExpression(node); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: return emitClassDeclaration(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return emitEnumMember(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: return emitImportDeclaration(node); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return emitExportDeclaration(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return emitExportAssignment(node); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return emitSourceFileNode(node); } } @@ -38317,7 +39314,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 === 251 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 252 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -38332,7 +39329,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 251 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 252 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentText, node.end); } } @@ -38362,7 +39359,7 @@ var ts; // declare var x; // /// // interface F {} - // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted if (node.pos === 0) { leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); } @@ -38462,7 +39459,7 @@ var ts; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ var emptyArray = []; - ts.version = "1.8.0"; + ts.version = "1.9.0"; function findConfigFile(searchPath, fileExists) { var fileName = "tsconfig.json"; while (true) { @@ -38485,36 +39482,315 @@ var ts; 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, compilerOptions, host); - case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + function trace(host, message) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceModuleResolution && host.trace !== undefined; + } + function startsWith(str, prefix) { + return str.lastIndexOf(prefix, 0) === 0; + } + function endsWith(str, suffix) { + var expectedPos = str.length - suffix.length; + return str.indexOf(suffix, expectedPos) === expectedPos; + } + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42 /* asterisk */) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + // have already seen asterisk + return false; + } + } } + return true; + } + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + } + function moduleHasNonRelativeName(moduleName) { + if (ts.isRootedDiskPath(moduleName)) { + return false; + } + var i = moduleName.lastIndexOf("./", 1); + var startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === 46 /* dot */); + return !startsWithDotSlashOrDotDotSlash; + } + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; } ts.resolveModuleName = resolveModuleName; + /** + * Any module resolution kind can be augmented with optional settings: 'baseUrl', 'paths' and 'rootDirs' - they are used to + * mitigate differences between design time structure of the project and its runtime counterpart so the same import name + * can be resolved successfully by TypeScript compiler and runtime module loader. + * If these settings are set then loading procedure will try to use them to resolve module name and it can of failure it will + * fallback to standard resolution routine. + * + * - baseUrl - this setting controls how non-relative module names are resolved. If this setting is specified then non-relative + * names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then candidate location to resolve module name 'c/d' will + * be '/a/b/c/d' + * - paths - this setting can only be used when baseUrl is specified. allows to tune how non-relative module names + * will be resolved based on the content of the module name. + * Structure of 'paths' compiler options + * 'paths': { + * pattern-1: [...substitutions], + * pattern-2: [...substitutions], + * ... + * pattern-n: [...substitutions] + * } + * Pattern here is a string that can contain zero or one '*' character. During module resolution module name will be matched against + * all patterns in the list. Matching for patterns that don't contain '*' means that module name must be equal to pattern respecting the case. + * If pattern contains '*' then to match pattern "*" module name must start with the and end with . + * denotes part of the module name between and . + * If module name can be matches with multiple patterns then pattern with the longest prefix will be picked. + * After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module + * from the candidate location. + * Substitution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every + * substitution in the list and replace '*' with string. If candidate location is not rooted it + * will be converted to absolute using baseUrl. + * For example: + * baseUrl: /a/b/c + * "paths": { + * // match all module names + * "*": [ + * "*", // use matched name as is, + * // will be looked as /a/b/c/ + * + * "folder1/*" // substitution will convert matched name to 'folder1/', + * // since it is not rooted then final candidate location will be /a/b/c/folder1/ + * ], + * // match module names that start with 'components/' + * "components/*": [ "/root/components/*" ] // substitution will convert /components/folder1/ to '/root/components/folder1/', + * // it is rooted so it will be final candidate location + * } + * + * 'rootDirs' allows the project to be spreaded across multiple locations and resolve modules with relative names as if + * they were in the same location. For example lets say there are two files + * '/local/src/content/file1.ts' + * '/shared/components/contracts/src/content/protocols/file2.ts' + * After bundling content of '/shared/components/contracts/src' will be merged with '/local/src' so + * if file1 has the following import 'import {x} from "./protocols/file2"' it will be resolved successfully in runtime. + * 'rootDirs' provides the way to tell compiler that in order to get the whole project it should behave as if content of all + * root dirs were merged together. + * I.e. for the example above 'rootDirs' will have two entries: [ '/local/src', '/shared/components/contracts/src' ]. + * Compiler will first convert './protocols/file2' into absolute path relative to the location of containing file: + * '/local/src/content/protocols/file2' and try to load it - failure. + * Then it will search 'rootDirs' looking for a longest matching prefix of this absolute path and if such prefix is found - absolute path will + * be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining + * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. + */ + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } + } + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + // rootDirs are expected to be absolute + // in case of tsconfig.json this will happen automatically - compiler will expand relative names + // using location of tsconfig.json as base location + var normalizedRoot = ts.normalizePath(rootDir); + if (!endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + // first - try to load from a initial location + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + // then try to resolve using remaining entries in rootDirs + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + // skip the initially matched entry + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var longestMatchPrefixLength = -1; + var matchedPattern; + var matchedStar; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + for (var key in state.compilerOptions.paths) { + var pattern = key; + var indexOfStar = pattern.indexOf("*"); + if (indexOfStar !== -1) { + var prefix = pattern.substr(0, indexOfStar); + var suffix = pattern.substr(indexOfStar + 1); + if (moduleName.length >= prefix.length + suffix.length && + startsWith(moduleName, prefix) && + endsWith(moduleName, suffix)) { + // use length of prefix as betterness criteria + if (prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = prefix.length; + matchedPattern = pattern; + matchedStar = moduleName.substr(prefix.length, moduleName.length - suffix.length); + } + } + } + else if (pattern === moduleName) { + // pattern was matched as is - no need to search further + matchedPattern = pattern; + matchedStar = undefined; + break; + } + } + } + if (matchedPattern) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPattern); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPattern]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("\*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { - var failedLookupLocations = []; - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(supportedExtensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, host); - if (resolvedFileName) { - return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); + } + var isExternalLibraryImport = false; + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, host); - return resolvedFileName - ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state); + isExternalLibraryImport = resolvedFileName !== undefined; } else { - return loadModuleFromNodeModules(moduleName, containingDirectory, host); + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + } /* @internal */ function directoryProbablyExists(directoryName, host) { // if host does not support 'directoryExists' assume that directory will exist @@ -38525,63 +39801,90 @@ var ts; * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ - function loadNodeModuleFromFile(extensions, candidate, failedLookupLocation, onlyRecordFailures, host) { + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { return ts.forEach(extensions, tryLoad); function tryLoad(ext) { + if (ext === ".tsx" && state.skipTsx) { + return undefined; + } var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (!onlyRecordFailures && host.fileExists(fileName)) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_module_resolution_result, fileName); + } return fileName; } else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } failedLookupLocation.push(fileName); return undefined; } } } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, host) { + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, host); - if (directoryExists && host.fileExists(packageJsonPath)) { - var jsonContent; + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var jsonContent = void 0; try { - var jsonText = host.readFile(packageJsonPath); + var jsonText = state.host.readFile(packageJsonPath); jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; } catch (e) { - // gracefully handle if readFile fails or returns not JSON + // gracefully handle if readFile fails or returns not JSON jsonContent = { typings: undefined }; } - if (typeof jsonContent.typings === "string") { - var path = ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)); - var result = loadNodeModuleFromFile(extensions, path, failedLookupLocation, !directoryProbablyExists(ts.getDirectoryPath(path), host), host); - if (result) { - return result; + if (jsonContent.typings) { + if (typeof jsonContent.typings === "string") { + var typingsFile = ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_typings_field_0_that_references_1, jsonContent.typings, typingsFile); + } + var result = loadModuleFromFile(typingsFile, extensions, failedLookupLocation, !directoryProbablyExists(ts.getDirectoryPath(typingsFile), state.host), state); + if (result) { + return result; + } + } + else if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_typings_field_in_package_json_to_be_string_got_0, typeof jsonContent.typings); + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_typings_field); } } } else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, host); + return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); } - function loadModuleFromNodeModules(moduleName, directory, host) { - var failedLookupLocations = []; + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state) { directory = ts.normalizeSlashes(directory); while (true) { var baseName = ts.getBaseFileName(directory); if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, host); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); // Load only typescript files irrespective of allowJs option if loading from node modules - var result = loadNodeModuleFromFile(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host); + var result = loadModuleFromFile(candidate, ts.supportedTypeScriptExtensions, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + return result; } - result = loadNodeModuleFromDirectory(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host); + result = loadNodeModuleFromDirectory(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + return result; } } var parentPath = ts.getDirectoryPath(directory); @@ -38590,46 +39893,36 @@ var ts; } directory = parentPath; } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - function nameStartsWithDotSlashOrDotDotSlash(name) { - var i = name.lastIndexOf("./", 1); - return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + return undefined; } 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 { resolvedModule: undefined, failedLookupLocations: [] }; - } - var searchPath = ts.getDirectoryPath(containingFile); - var searchName; + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; var failedLookupLocations = []; - var referencedSourceFile; var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(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 containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); + } + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + if (referencedSourceFile) { + break; } - var candidate = searchName + extension; - if (host.fileExists(candidate)) { - return candidate; + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + break; } - else { - failedLookupLocations.push(candidate); - } - }); - if (referencedSourceFile) { - break; + containingDirectory = parentPath; } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); } return referencedSourceFile ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } @@ -38638,7 +39931,7 @@ var ts; ts.classicNameResolver = classicNameResolver; /* @internal */ ts.defaultInitCompilerOptions = { - module: 1 /* CommonJS */, + module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, noImplicitAny: false, sourceMap: false @@ -38710,6 +40003,7 @@ var ts; getNewLine: function () { return newLine; }, fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, readFile: function (fileName) { return ts.sys.readFile(fileName); }, + trace: function (s) { return ts.sys.write(s + newLine); }, directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); } }; } @@ -38784,7 +40078,7 @@ var ts; }); var filesByName = ts.createFileMap(); // stores 'filename -> file association' ignoring case - // used to track cases when two file names differ only in casing + // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (oldProgram) { // check properties that can affect structure of the program or module resolution strategy @@ -38977,13 +40271,20 @@ var ts; return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + var declarationDiagnostics = []; + if (options.noEmit) { + return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true }; + } // 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) { - var preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken); - if (preEmitDiagnostics.length > 0) { - return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true }; + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (diagnostics.length === 0 && program.getCompilerOptions().declaration) { + declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); + } + if (diagnostics.length > 0 || declarationDiagnostics.length > 0) { + return { diagnostics: diagnostics, sourceMaps: undefined, emitSkipped: true }; } } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -39037,7 +40338,7 @@ var ts; // We were canceled while performing the operation. Because our type checker // might be a bad state, we need to throw it away. // - // Note: we are overly agressive here. We do not actually *have* to throw away + // Note: we are overly aggressive here. We do not actually *have* to throw away // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep // the lifetimes of these two TypeCheckers the same. Also, we generally only // cancel when the user has made a change anyways. And, in that case, we (the @@ -39075,44 +40376,47 @@ var ts; return false; } switch (node.kind) { - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 230 /* ExportAssignment */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - case 217 /* ClassDeclaration */: + case 231 /* ExportAssignment */: + if (node.isExportEquals) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 218 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 246 /* HeritageClause */: + case 247 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 106 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: - case 216 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -39120,20 +40424,20 @@ var ts; return true; } break; - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 214 /* VariableDeclaration */: + case 215 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start_2 = expression.typeArguments.pos; @@ -39141,7 +40445,7 @@ var ts; return true; } break; - case 139 /* Parameter */: + case 140 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start_3 = parameter.modifiers.pos; @@ -39157,18 +40461,20 @@ var ts; return true; } break; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 174 /* TypeAssertionExpression */: + case 175 /* 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 140 /* Decorator */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); + case 141 /* Decorator */: + if (!options.experimentalDecorators) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + } return true; } return ts.forEachChild(node, walk); @@ -39196,6 +40502,7 @@ var ts; case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: + case 127 /* ReadonlyKeyword */: case 122 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; @@ -39268,9 +40575,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 225 /* ImportDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 231 /* ExportDeclaration */: + case 226 /* ImportDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 232 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -39279,14 +40586,14 @@ var ts; break; } // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules // only through top - level external module names. Relative external module names are not permitted. if (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { (imports || (imports = [])).push(moduleNameExpr); } break; - case 221 /* ModuleDeclaration */: - if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { + case 222 /* ModuleDeclaration */: + if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. // This will happen in two cases: @@ -39297,7 +40604,7 @@ var ts; (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); } else if (!inAmbientModule) { - // An AmbientExternalModuleDeclaration declares an external module. + // 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 @@ -39311,7 +40618,7 @@ var ts; } } function collectRequireCalls(node) { - if (ts.isRequireCall(node)) { + if (ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { (imports || (imports = [])).push(node.arguments[0]); } else { @@ -39435,7 +40742,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); // add file to program only if: - // - resolution was successfull + // - resolution was successful // - noResolve is falsy // - module name come from the list fo imports var shouldAddFile = resolution && @@ -39446,7 +40753,7 @@ var ts; if (importedFile && resolution.isExternalLibraryImport) { // Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files, // this check is ok. Otherwise this would be never true for javascript file - if (!ts.isExternalModule(importedFile)) { + if (!ts.isExternalModule(importedFile) && importedFile.statements.length) { var start_5 = ts.getTokenPosOfNode(file.imports[i], file); fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_5, file.imports[i].end - start_5, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); } @@ -39543,6 +40850,25 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } } + if (options.paths && options.baseUrl === undefined) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option)); + } + if (options.paths) { + for (var key in options.paths) { + if (!ts.hasProperty(options.paths, key)) { + continue; + } + if (!hasZeroOrOneAsteriskCharacter(key)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); + } + for (var _i = 0, _a = options.paths[key]; _i < _a.length; _i++) { + var subst = _a[_i]; + if (!hasZeroOrOneAsteriskCharacter(subst)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); + } + } + } + } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); @@ -39567,7 +40893,7 @@ var ts; 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 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES6 */) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -39576,17 +40902,17 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { + else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); } // Cannot specify module gen target of es6 when below es6 - if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { + if (options.module === ts.ModuleKind.ES6 && languageVersion < 2 /* ES6 */) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); } // Cannot specify module gen that isn't amd or system with --out - if (outFile && options.module && !(options.module === 2 /* AMD */ || options.module === 4 /* System */)) { + if (outFile && options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); } // there has to be common source directory if user specified --outdir || --sourceRoot @@ -39623,15 +40949,15 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.reactNamespace && !ts.isIdentifier(options.reactNamespace, languageVersion)) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); } // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files - if (!options.noEmit) { + if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); - var emitFilesSeen = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); + var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { - verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen); - verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen); + verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); + verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); } // Verify that all the emit files are unique and don't overwrite input files @@ -39740,16 +41066,17 @@ var ts; name: "module", shortName: "m", type: { - "commonjs": 1 /* CommonJS */, - "amd": 2 /* AMD */, - "system": 4 /* System */, - "umd": 3 /* UMD */, - "es6": 5 /* ES6 */, - "es2015": 5 /* ES2015 */ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES6, + "es2015": ts.ModuleKind.ES2015 }, description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none }, { name: "newLine", @@ -39916,8 +41243,8 @@ var ts; { name: "moduleResolution", type: { - "node": 2 /* NodeJs */, - "classic": 1 /* Classic */ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic }, description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic @@ -39948,14 +41275,45 @@ var ts; description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { - name: "allowSyntheticDefaultImports", + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "rootDirs", + type: "object", + isTSConfigOnly: true, + isFilePath: true + }, + { + name: "traceModuleResolution", type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + description: ts.Diagnostics.Enable_tracing_of_the_module_resolution_process }, { name: "allowJs", type: "boolean", description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output } ]; var optionNameMapCache; @@ -40003,33 +41361,38 @@ var ts; } if (ts.hasProperty(optionNameMap, s)) { var opt = optionNameMap[s]; - // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - // If not a primitive, the possible types are specified in what is effectively a map of options. - default: - var map_1 = opt.type; - var key = (args[i] || "").toLowerCase(); - i++; - if (ts.hasProperty(map_1, key)) { - options[opt.name] = map_1[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - } + else { + // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + var map_1 = opt.type; + var key = (args[i] || "").toLowerCase(); + i++; + if (ts.hasProperty(map_1, key)) { + options[opt.name] = map_1[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + } + } } } else { @@ -40138,9 +41501,9 @@ var ts; * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json, host, basePath, existingOptions) { + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName) { if (existingOptions === void 0) { existingOptions = {}; } - var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), optionsFromJsonConfigFile = _a.options, errors = _a.errors; + var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath, configFileName), optionsFromJsonConfigFile = _a.options, errors = _a.errors; var options = ts.extend(existingOptions, optionsFromJsonConfigFile); return { options: options, @@ -40159,7 +41522,19 @@ var ts; } else { var filesSeen = {}; - var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; + var exclude = []; + if (json["exclude"] instanceof Array) { + exclude = json["exclude"]; + } + else { + // by default exclude node_modules, and any specificied output directory + exclude = ["node_modules"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + exclude.push(outDir); + } + } + exclude = ts.map(exclude, ts.normalizeSlashes); var supportedExtensions = ts.getSupportedExtensions(options); ts.Debug.assert(ts.indexOf(supportedExtensions, ".ts") < ts.indexOf(supportedExtensions, ".d.ts"), "Changed priority of extensions to pick"); // Get files of supported extensions in their order of resolution @@ -40168,11 +41543,15 @@ var ts; var filesInDirWithExtension = host.readDirectory(basePath, extension, exclude); for (var _a = 0, filesInDirWithExtension_1 = filesInDirWithExtension; _a < filesInDirWithExtension_1.length; _a++) { var fileName = filesInDirWithExtension_1[_a]; - // .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension, + // .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension, // lets pick them when its turn comes up if (extension === ".ts" && ts.fileExtensionIs(fileName, ".d.ts")) { continue; } + // Skip over any minified JavaScript files (ending in ".min.js") + if (/\.min\.js$/.test(fileName)) { + continue; + } // If this is one of the output extension (which would be .d.ts and .js if we are allowing compilation of js files) // do not include this file if we included .ts or .tsx file with same base name as it could be output of the earlier compilation if (extension === ".d.ts" || (options.allowJs && ts.contains(ts.supportedJavascriptExtensions, extension))) { @@ -40190,9 +41569,12 @@ var ts; } } ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompilerOptionsFromJson(jsonOptions, basePath) { + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var options = {}; var errors = []; + if (configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json") { + options.allowJs = true; + } if (!jsonOptions) { return { options: options, errors: errors }; } @@ -40215,7 +41597,37 @@ var ts; } } if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + switch (typeof value) { + case "string": + value = ts.normalizePath(ts.combinePaths(basePath, value)); + break; + case "object": + // "object" options with 'isFilePath' = true expected to be string arrays + var paths = []; + var invalidOptionType = false; + if (!ts.isArray(value)) { + invalidOptionType = true; + } + else { + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + if (typeof element === "string") { + paths.push(ts.normalizePath(ts.combinePaths(basePath, element))); + } + else { + invalidOptionType = true; + break; + } + } + } + if (invalidOptionType) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_should_have_array_of_strings_as_a_value, opt.name)); + } + else { + value = paths; + } + break; + } if (value === "") { value = "."; } @@ -40306,7 +41718,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 177 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 178 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -40318,30 +41730,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 195 /* Block */: + case 196 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; + var parent_9 = 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 === 200 /* DoStatement */ || - parent_8.kind === 203 /* ForInStatement */ || - parent_8.kind === 204 /* ForOfStatement */ || - parent_8.kind === 202 /* ForStatement */ || - parent_8.kind === 199 /* IfStatement */ || - parent_8.kind === 201 /* WhileStatement */ || - parent_8.kind === 208 /* WithStatement */ || - parent_8.kind === 247 /* CatchClause */) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + if (parent_9.kind === 201 /* DoStatement */ || + parent_9.kind === 204 /* ForInStatement */ || + parent_9.kind === 205 /* ForOfStatement */ || + parent_9.kind === 203 /* ForStatement */ || + parent_9.kind === 200 /* IfStatement */ || + parent_9.kind === 202 /* WhileStatement */ || + parent_9.kind === 209 /* WithStatement */ || + parent_9.kind === 248 /* CatchClause */) { + addOutliningSpan(parent_9, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 212 /* TryStatement */) { + if (parent_9.kind === 213 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_8; + var tryStatement = parent_9; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_9, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -40364,23 +41776,23 @@ var ts; break; } // Fallthrough. - case 222 /* ModuleBlock */: { + case 223 /* 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 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 168 /* ObjectLiteralExpression */: - case 223 /* CaseBlock */: { + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 169 /* ObjectLiteralExpression */: + case 224 /* 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 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -40419,8 +41831,8 @@ var ts; if (!matches) { continue; } - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { @@ -40473,7 +41885,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 137 /* ComputedPropertyName */) { + else if (declaration.name.kind === 138 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -40494,7 +41906,7 @@ var ts; } return true; } - if (expression.kind === 169 /* PropertyAccessExpression */) { + if (expression.kind === 170 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -40507,7 +41919,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 137 /* ComputedPropertyName */) { + if (declaration.name.kind === 138 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -40581,17 +41993,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 221 /* ModuleDeclaration */: + case 222 /* 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 === 221 /* ModuleDeclaration */); + } while (current.kind === 222 /* ModuleDeclaration */); // fall through - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -40602,21 +42014,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 231 /* ExportDeclaration */: + case 232 /* 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 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -40628,7 +42040,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 228 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -40637,21 +42049,21 @@ var ts; } } break; - case 166 /* BindingElement */: - case 214 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 215 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 218 /* InterfaceDeclaration */: - case 221 /* ModuleDeclaration */: - case 216 /* FunctionDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 229 /* ImportSpecifier */: - case 233 /* ExportSpecifier */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 219 /* InterfaceDeclaration */: + case 222 /* ModuleDeclaration */: + case 217 /* FunctionDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 230 /* ImportSpecifier */: + case 234 /* ExportSpecifier */: childNodes.push(node); break; } @@ -40699,17 +42111,17 @@ var ts; for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; switch (node.kind) { - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 219 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -40720,12 +42132,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 216 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 217 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 195 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 196 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 216 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 217 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -40785,44 +42197,44 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 139 /* Parameter */: + case 140 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 1022 /* Modifier */) === 0) { + if ((node.flags & 959 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 146 /* GetAccessor */: + case 147 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 147 /* SetAccessor */: + case 148 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 148 /* CallSignature */: + case 149 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: - var variableDeclarationNode; + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: + var variableDeclarationNode = void 0; var name_32; - if (node.kind === 166 /* BindingElement */) { + if (node.kind === 167 /* BindingElement */) { name_32 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 214 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 215 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -40841,13 +42253,13 @@ var ts; else { return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.variableElement); } - case 145 /* Constructor */: + case 146 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 233 /* ExportSpecifier */: - case 229 /* ImportSpecifier */: - case 224 /* ImportEqualsDeclaration */: - case 226 /* ImportClause */: - case 227 /* NamespaceImport */: + case 234 /* ExportSpecifier */: + case 230 /* ImportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 227 /* ImportClause */: + case 228 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -40877,17 +42289,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: return createSourceFileItem(node); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: return createClassItem(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return createEnumItem(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return createModuleItem(node); - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -40899,7 +42311,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 221 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 222 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -40911,7 +42323,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 === 195 /* Block */) { + if (node.body && node.body.kind === 196 /* 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)); } @@ -40932,7 +42344,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 145 /* Constructor */ && member; + return member.kind === 146 /* 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 @@ -40956,7 +42368,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 137 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 138 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -40965,13 +42377,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 221 /* ModuleDeclaration */) { + while (node.body.kind === 222 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 251 /* SourceFile */ + return node.kind === 252 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -41722,7 +43134,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 171 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 172 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -41730,7 +43142,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 69 /* Identifier */ ? expression - : expression.kind === 169 /* PropertyAccessExpression */ + : expression.kind === 170 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -41742,8 +43154,8 @@ var ts; var nameToDeclarations = sourceFile_1.getNamedDeclarations(); var declarations = ts.getProperty(nameToDeclarations, name.text); if (declarations) { - for (var _b = 0, declarations_7 = declarations; _b < declarations_7.length; _b++) { - var declaration = declarations_7[_b]; + for (var _b = 0, declarations_8 = declarations; _b < declarations_8.length; _b++) { + var declaration = declarations_8[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -41763,7 +43175,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 171 /* CallExpression */ || node.parent.kind === 172 /* NewExpression */) { + if (node.parent.kind === 172 /* CallExpression */ || node.parent.kind === 173 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -41816,25 +43228,25 @@ var ts; }; } } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 173 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 174 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 173 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 174 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 186 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 187 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 193 /* TemplateSpan */ && node.parent.parent.parent.kind === 173 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 194 /* TemplateSpan */ && node.parent.parent.parent.kind === 174 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 186 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 187 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -41952,7 +43364,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 186 /* TemplateExpression */) { + if (template.kind === 187 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -41961,7 +43373,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 251 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 252 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -42161,40 +43573,40 @@ var ts; return false; } switch (n.kind) { - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 168 /* ObjectLiteralExpression */: - case 164 /* ObjectBindingPattern */: - case 156 /* TypeLiteral */: - case 195 /* Block */: - case 222 /* ModuleBlock */: - case 223 /* CaseBlock */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 169 /* ObjectLiteralExpression */: + case 165 /* ObjectBindingPattern */: + case 157 /* TypeLiteral */: + case 196 /* Block */: + case 223 /* ModuleBlock */: + case 224 /* CaseBlock */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 172 /* NewExpression */: + case 173 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 171 /* CallExpression */: - case 175 /* ParenthesizedExpression */: - case 161 /* ParenthesizedType */: + case 172 /* CallExpression */: + case 176 /* ParenthesizedExpression */: + case 162 /* ParenthesizedType */: return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 149 /* ConstructSignature */: - case 148 /* CallSignature */: - case 177 /* ArrowFunction */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 150 /* ConstructSignature */: + case 149 /* CallSignature */: + case 178 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -42204,64 +43616,64 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 199 /* IfStatement */: + case 200 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 23 /* SemicolonToken */); - case 167 /* ArrayLiteralExpression */: - case 165 /* ArrayBindingPattern */: - case 170 /* ElementAccessExpression */: - case 137 /* ComputedPropertyName */: - case 158 /* TupleType */: + case 168 /* ArrayLiteralExpression */: + case 166 /* ArrayBindingPattern */: + case 171 /* ElementAccessExpression */: + case 138 /* ComputedPropertyName */: + case 159 /* TupleType */: return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 244 /* CaseClause */: - case 245 /* DefaultClause */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 201 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 202 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 200 /* DoStatement */: + case 201 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 179 /* TypeOfExpression */: - case 178 /* DeleteExpression */: - case 180 /* VoidExpression */: - case 187 /* YieldExpression */: - case 188 /* SpreadElementExpression */: + case 180 /* TypeOfExpression */: + case 179 /* DeleteExpression */: + case 181 /* VoidExpression */: + case 188 /* YieldExpression */: + case 189 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 193 /* TemplateSpan */: + case 194 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -42317,7 +43729,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 === 274 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 275 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -42423,7 +43835,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 239 /* JsxText */) { + if (isToken(n) || n.kind === 240 /* JsxText */) { return n; } var children = n.getChildren(); @@ -42431,7 +43843,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 239 /* JsxText */) { + if (isToken(n) || n.kind === 240 /* JsxText */) { return n; } var children = n.getChildren(); @@ -42445,10 +43857,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 239 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 240 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 239 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 240 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -42460,7 +43872,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 251 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 252 /* 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. @@ -42482,7 +43894,7 @@ var ts; ts.findPrecedingToken = findPrecedingToken; function isInString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position); - return token && (token.kind === 9 /* StringLiteral */ || token.kind === 163 /* StringLiteralType */) && position > token.getStart(); + return token && (token.kind === 9 /* StringLiteral */ || token.kind === 164 /* StringLiteralType */) && position > token.getStart(); } ts.isInString = isInString; function isInComment(sourceFile, position) { @@ -42568,17 +43980,17 @@ var ts; function getNodeModifiers(node) { var flags = ts.getCombinedNodeFlags(node); var result = []; - if (flags & 16 /* Private */) + if (flags & 8 /* Private */) result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 32 /* Protected */) + if (flags & 16 /* Protected */) result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 8 /* Public */) + if (flags & 4 /* Public */) result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 64 /* Static */) + if (flags & 32 /* Static */) result.push(ts.ScriptElementKindModifier.staticModifier); if (flags & 128 /* Abstract */) result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 2 /* Export */) + if (flags & 1 /* Export */) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) result.push(ts.ScriptElementKindModifier.ambientModifier); @@ -42586,17 +43998,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 152 /* TypeReference */ || node.kind === 171 /* CallExpression */) { + if (node.kind === 153 /* TypeReference */ || node.kind === 172 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 217 /* ClassDeclaration */ || node.kind === 218 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 218 /* ClassDeclaration */ || node.kind === 219 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 135 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 136 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -42612,7 +44024,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 163 /* StringLiteralType */ + || kind === 164 /* StringLiteralType */ || kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; @@ -42656,18 +44068,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 167 /* ArrayLiteralExpression */ || - node.kind === 168 /* ObjectLiteralExpression */) { + if (node.kind === 168 /* ArrayLiteralExpression */ || + node.kind === 169 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 184 /* BinaryExpression */ && + if (node.parent.kind === 185 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 56 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 204 /* ForOfStatement */ && + if (node.parent.kind === 205 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -42675,7 +44087,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 248 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 249 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -42688,7 +44100,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 139 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 140 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -42876,7 +44288,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 229 /* ImportSpecifier */ || location.parent.kind === 233 /* ExportSpecifier */) && + (location.parent.kind === 230 /* ImportSpecifier */ || location.parent.kind === 234 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -42999,10 +44411,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 241 /* JsxAttribute */: - case 238 /* JsxOpeningElement */: - case 240 /* JsxClosingElement */: - case 237 /* JsxSelfClosingElement */: + case 242 /* JsxAttribute */: + case 239 /* JsxOpeningElement */: + case 241 /* JsxClosingElement */: + case 238 /* JsxSelfClosingElement */: return node.kind === 69 /* Identifier */; } } @@ -43391,25 +44803,25 @@ 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, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* 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, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* 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(53 /* 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(53 /* 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 */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - 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 */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* 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 */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext), 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 */)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); @@ -43422,7 +44834,7 @@ var ts; // 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(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 */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. 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] @@ -43430,79 +44842,79 @@ var ts; // 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(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* 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, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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(41 /* 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 */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* 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 */, 42 /* 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([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), 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([108 /* LetKeyword */, 74 /* 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.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* 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(103 /* 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(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* 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 */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 130 /* SetKeyword */]), 69 /* 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 */)); + this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // 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(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 128 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), 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([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 130 /* SetKeyword */, 113 /* StaticKeyword */, 133 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34 /* EqualsGreaterThanToken */), 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 */)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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 */)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* 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.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* 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([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 130 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* 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([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* 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([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // template string - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -43563,13 +44975,13 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), 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 */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */)); + this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements 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 */)); @@ -43581,25 +44993,25 @@ var ts; // Open Brace braces after control block 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(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 */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - 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 */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing template string braces - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Insert space after function keyword for anonymous functions this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); @@ -43617,40 +45029,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 202 /* ForStatement */; + return context.contextNode.kind === 203 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 184 /* BinaryExpression */: - case 185 /* ConditionalExpression */: - case 192 /* AsExpression */: - case 151 /* TypePredicate */: - case 159 /* UnionType */: - case 160 /* IntersectionType */: + case 185 /* BinaryExpression */: + case 186 /* ConditionalExpression */: + case 193 /* AsExpression */: + case 152 /* TypePredicate */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 166 /* BindingElement */: + case 167 /* BindingElement */: // equals in type X = ... - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 214 /* VariableDeclaration */: + case 215 /* VariableDeclaration */: // equal in p = 0; - case 139 /* Parameter */: - case 250 /* EnumMember */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 140 /* Parameter */: + case 251 /* EnumMember */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 203 /* ForInStatement */: + case 204 /* ForInStatement */: return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 204 /* ForOfStatement */: - return context.currentTokenSpan.kind === 135 /* OfKeyword */ || context.nextTokenSpan.kind === 135 /* OfKeyword */; + case 205 /* ForOfStatement */: + return context.currentTokenSpan.kind === 136 /* OfKeyword */ || context.nextTokenSpan.kind === 136 /* OfKeyword */; } return false; }; @@ -43658,7 +45070,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 185 /* ConditionalExpression */; + return context.contextNode.kind === 186 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -43702,93 +45114,93 @@ var ts; return true; } switch (node.kind) { - case 195 /* Block */: - case 223 /* CaseBlock */: - case 168 /* ObjectLiteralExpression */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 224 /* CaseBlock */: + case 169 /* ObjectLiteralExpression */: + case 223 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 148 /* CallSignature */: - case 176 /* FunctionExpression */: - case 145 /* Constructor */: - case 177 /* ArrowFunction */: + case 149 /* CallSignature */: + case 177 /* FunctionExpression */: + case 146 /* Constructor */: + case 178 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 216 /* FunctionDeclaration */ || context.contextNode.kind === 176 /* FunctionExpression */; + return context.contextNode.kind === 217 /* FunctionDeclaration */ || context.contextNode.kind === 177 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 156 /* TypeLiteral */: - case 221 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 157 /* TypeLiteral */: + case 222 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 217 /* ClassDeclaration */: - case 221 /* ModuleDeclaration */: - case 220 /* EnumDeclaration */: - case 195 /* Block */: - case 247 /* CatchClause */: - case 222 /* ModuleBlock */: - case 209 /* SwitchStatement */: + case 218 /* ClassDeclaration */: + case 222 /* ModuleDeclaration */: + case 221 /* EnumDeclaration */: + case 196 /* Block */: + case 248 /* CatchClause */: + case 223 /* ModuleBlock */: + case 210 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 199 /* IfStatement */: - case 209 /* SwitchStatement */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 201 /* WhileStatement */: - case 212 /* TryStatement */: - case 200 /* DoStatement */: - case 208 /* WithStatement */: + case 200 /* IfStatement */: + case 210 /* SwitchStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 202 /* WhileStatement */: + case 213 /* TryStatement */: + case 201 /* DoStatement */: + case 209 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 247 /* CatchClause */: + case 248 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 168 /* ObjectLiteralExpression */; + return context.contextNode.kind === 169 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 171 /* CallExpression */; + return context.contextNode.kind === 172 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 172 /* NewExpression */; + return context.contextNode.kind === 173 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -43800,10 +45212,10 @@ var ts; return context.nextTokenSpan.kind !== 20 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 177 /* ArrowFunction */; + return context.contextNode.kind === 178 /* ArrowFunction */; }; - Rules.IsSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine(); + Rules.IsNonJsxSameLineTokenContext = function (context) { + return context.TokensAreOnSameLine() && context.contextNode.kind !== 240 /* JsxText */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -43818,41 +45230,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 140 /* Decorator */; + return node.kind === 141 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 215 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 216 /* 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 === 221 /* ModuleDeclaration */; + return context.contextNode.kind === 222 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 156 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 157 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 152 /* TypeReference */: - case 174 /* TypeAssertionExpression */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 191 /* ExpressionWithTypeArguments */: + case 153 /* TypeReference */: + case 175 /* TypeAssertionExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 192 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -43863,13 +45275,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 174 /* TypeAssertionExpression */; + return context.contextNode.kind === 175 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 180 /* VoidExpression */; + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 181 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 187 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 188 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -43893,7 +45305,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 135 /* LastToken */ + 1; + this.mapRowLength = 136 /* 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); @@ -44088,7 +45500,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 135 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 136 /* LastToken */; token++) { result.push(token); } return result; @@ -44130,9 +45542,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 135 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 136 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 135 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 136 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); @@ -44140,7 +45552,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 129 /* NumberKeyword */, 131 /* StringKeyword */, 120 /* BooleanKeyword */, 132 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); return TokenRange; }()); Shared.TokenRange = TokenRange; @@ -44362,17 +45774,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 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 195 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 251 /* SourceFile */: - case 195 /* Block */: - case 222 /* ModuleBlock */: + return body && body.kind === 196 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 252 /* SourceFile */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -44574,19 +45986,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 217 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 218 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 216 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 220 /* EnumDeclaration */: return 220 /* EnumDeclaration */; - case 146 /* GetAccessor */: return 123 /* GetKeyword */; - case 147 /* SetAccessor */: return 129 /* SetKeyword */; - case 144 /* MethodDeclaration */: + case 218 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 219 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 217 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 221 /* EnumDeclaration */: return 221 /* EnumDeclaration */; + case 147 /* GetAccessor */: return 123 /* GetKeyword */; + case 148 /* SetAccessor */: return 130 /* SetKeyword */; + case 145 /* MethodDeclaration */: if (node.asteriskToken) { return 37 /* AsteriskToken */; } // fall-through - case 142 /* PropertyDeclaration */: - case 139 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 140 /* Parameter */: return node.name.kind; } } @@ -44726,7 +46138,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 140 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 141 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -45070,20 +46482,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 195 /* Block */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 145 /* Constructor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 177 /* ArrowFunction */: + case 146 /* Constructor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 178 /* ArrowFunction */: if (node.typeParameters === list) { return 25 /* LessThanToken */; } @@ -45091,8 +46503,8 @@ var ts; return 17 /* OpenParenToken */; } break; - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -45100,7 +46512,7 @@ var ts; return 17 /* OpenParenToken */; } break; - case 152 /* TypeReference */: + case 153 /* TypeReference */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -45129,7 +46541,7 @@ var ts; if (!options.ConvertTabsToSpaces) { var tabs = Math.floor(indentation / options.TabSize); var spaces = indentation - tabs * options.TabSize; - var tabString; + var tabString = void 0; if (!internedTabsIndentation) { internedTabsIndentation = []; } @@ -45142,7 +46554,7 @@ var ts; return spaces ? tabString + repeat(" ", spaces) : tabString; } else { - var spacesString; + var spacesString = void 0; var quotient = Math.floor(indentation / options.IndentSize); var remainder = indentation % options.IndentSize; if (!internedSpacesIndentation) { @@ -45216,7 +46628,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 184 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 185 /* 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 */) { @@ -45335,7 +46747,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 === 251 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 252 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -45368,7 +46780,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 199 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 200 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -45380,23 +46792,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 152 /* TypeReference */: + case 153 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return node.parent.properties; - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return node.parent.elements; - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: { + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -45407,8 +46819,8 @@ var ts; } break; } - case 172 /* NewExpression */: - case 171 /* CallExpression */: { + case 173 /* NewExpression */: + case 172 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -45438,8 +46850,8 @@ var ts; if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 171 /* CallExpression */ || - node.parent.kind === 172 /* NewExpression */) && + if (node.parent && (node.parent.kind === 172 /* CallExpression */ || + node.parent.kind === 173 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -45457,10 +46869,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: node = node.expression; break; default: @@ -45524,45 +46936,45 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 198 /* ExpressionStatement */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 167 /* ArrayLiteralExpression */: - case 195 /* Block */: - case 222 /* ModuleBlock */: - case 168 /* ObjectLiteralExpression */: - case 156 /* TypeLiteral */: - case 158 /* TupleType */: - case 223 /* CaseBlock */: - case 245 /* DefaultClause */: - case 244 /* CaseClause */: - case 175 /* ParenthesizedExpression */: - case 169 /* PropertyAccessExpression */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 196 /* VariableStatement */: - case 214 /* VariableDeclaration */: - case 230 /* ExportAssignment */: - case 207 /* ReturnStatement */: - case 185 /* ConditionalExpression */: - case 165 /* ArrayBindingPattern */: - case 164 /* ObjectBindingPattern */: - case 238 /* JsxOpeningElement */: - case 237 /* JsxSelfClosingElement */: - case 243 /* JsxExpression */: - case 143 /* MethodSignature */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 139 /* Parameter */: - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 161 /* ParenthesizedType */: - case 173 /* TaggedTemplateExpression */: - case 181 /* AwaitExpression */: - case 228 /* NamedImports */: + case 199 /* ExpressionStatement */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 168 /* ArrayLiteralExpression */: + case 196 /* Block */: + case 223 /* ModuleBlock */: + case 169 /* ObjectLiteralExpression */: + case 157 /* TypeLiteral */: + case 159 /* TupleType */: + case 224 /* CaseBlock */: + case 246 /* DefaultClause */: + case 245 /* CaseClause */: + case 176 /* ParenthesizedExpression */: + case 170 /* PropertyAccessExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 197 /* VariableStatement */: + case 215 /* VariableDeclaration */: + case 231 /* ExportAssignment */: + case 208 /* ReturnStatement */: + case 186 /* ConditionalExpression */: + case 166 /* ArrayBindingPattern */: + case 165 /* ObjectBindingPattern */: + case 239 /* JsxOpeningElement */: + case 238 /* JsxSelfClosingElement */: + case 244 /* JsxExpression */: + case 144 /* MethodSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 140 /* Parameter */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 162 /* ParenthesizedType */: + case 174 /* TaggedTemplateExpression */: + case 182 /* AwaitExpression */: + case 229 /* NamedImports */: return true; } return false; @@ -45571,22 +46983,22 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 202 /* ForStatement */: - case 199 /* IfStatement */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 144 /* MethodDeclaration */: - case 177 /* ArrowFunction */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - return childKind !== 195 /* Block */; - case 236 /* JsxElement */: - return childKind !== 240 /* JsxClosingElement */; + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 203 /* ForStatement */: + case 200 /* IfStatement */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 178 /* ArrowFunction */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + return childKind !== 196 /* Block */; + case 237 /* JsxElement */: + return childKind !== 241 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -45603,11 +47015,6 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// -var __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 __()); -}; /// /// /// @@ -45732,13 +47139,13 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 2048 /* Synthetic */, this)); + nodes.push(createNode(token, pos, textPos, 0, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(274 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); + var list = createNode(275 /* SyntaxList */, nodes.pos, nodes.end, 0, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -45757,27 +47164,27 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 136 /* FirstNode */) { + if (this.kind >= 137 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; - var pos = this.pos; + var pos_3 = this.pos; var processNode = function (node) { - if (pos < node.pos) { - pos = _this.addSyntheticNodes(children, pos, node.pos); + if (pos_3 < node.pos) { + pos_3 = _this.addSyntheticNodes(children, pos_3, node.pos); } children.push(node); - pos = node.end; + pos_3 = node.end; }; var processNodes = function (nodes) { - if (pos < nodes.pos) { - pos = _this.addSyntheticNodes(children, pos, nodes.pos); + if (pos_3 < nodes.pos) { + pos_3 = _this.addSyntheticNodes(children, pos_3, nodes.pos); } children.push(_this.createSyntaxList(nodes)); - pos = nodes.end; + pos_3 = nodes.end; }; ts.forEachChild(this, processNode, processNodes); - if (pos < this.end) { - this.addSyntheticNodes(children, pos, this.end); + if (pos_3 < this.end) { + this.addSyntheticNodes(children, pos_3, this.end); } scanner.setText(undefined); } @@ -45804,7 +47211,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 136 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 137 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -45812,7 +47219,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 136 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 137 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -45859,27 +47266,27 @@ var ts; // 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); + var sourceFileOfDeclaration_1 = 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 === 139 /* Parameter */) { - ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (canUseParsedParamTagComments && declaration.kind === 140 /* Parameter */) { + ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration_1), function (jsDocCommentTextRange) { + var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration_1); if (cleanedParamJsDocComment) { ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); } }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 221 /* ModuleDeclaration */ && declaration.body.kind === 221 /* ModuleDeclaration */) { + if (declaration.kind === 222 /* ModuleDeclaration */ && declaration.body.kind === 222 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 221 /* ModuleDeclaration */ && declaration.parent.kind === 221 /* ModuleDeclaration */) { + while (declaration.kind === 222 /* ModuleDeclaration */ && declaration.parent.kind === 222 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 214 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + ts.forEach(getJsDocCommentTextRange(declaration.kind === 215 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration_1), function (jsDocCommentTextRange) { + var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration_1); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); } @@ -45953,7 +47360,7 @@ var ts; else if (spacesToRemoveAfterAsterisk === undefined) { spacesToRemoveAfterAsterisk = 0; } - // Analyse text on this line + // Analyze text on this line while (pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { var ch = sourceFile.text.charAt(pos); if (ch === "@") { @@ -46073,7 +47480,7 @@ var ts; } paramHelpStringMargin = undefined; } - // If this is the start of another tag, continue with the loop in seach of param tag with symbol name + // If this is the start of another tag, continue with the loop in search of param tag with symbol name if (sourceFile.text.charCodeAt(pos) === 64 /* at */) { continue; } @@ -46223,9 +47630,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 137 /* ComputedPropertyName */) { + if (declaration.name.kind === 138 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 169 /* PropertyAccessExpression */) { + if (expr.kind === 170 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -46245,9 +47652,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -46267,60 +47674,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 220 /* EnumDeclaration */: - case 221 /* ModuleDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 233 /* ExportSpecifier */: - case 229 /* ImportSpecifier */: - case 224 /* ImportEqualsDeclaration */: - case 226 /* ImportClause */: - case 227 /* NamespaceImport */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 156 /* TypeLiteral */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 221 /* EnumDeclaration */: + case 222 /* ModuleDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 234 /* ExportSpecifier */: + case 230 /* ImportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 227 /* ImportClause */: + case 228 /* NamespaceImport */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 157 /* TypeLiteral */: addDeclaration(node); // fall through - case 145 /* Constructor */: - case 196 /* VariableStatement */: - case 215 /* VariableDeclarationList */: - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: - case 222 /* ModuleBlock */: + case 146 /* Constructor */: + case 197 /* VariableStatement */: + case 216 /* VariableDeclarationList */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: + case 223 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 195 /* Block */: + case 196 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 139 /* Parameter */: + case 140 /* Parameter */: // Only consider properties defined as constructor parameters - if (!(node.flags & 56 /* AccessibilityModifier */)) { + if (!(node.flags & 28 /* AccessibilityModifier */)) { break; } // fall through - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 250 /* EnumMember */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 251 /* EnumMember */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: addDeclaration(node); break; - case 231 /* ExportDeclaration */: + case 232 /* 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 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -46332,7 +47739,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 228 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -46554,16 +47961,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 176 /* FunctionExpression */) { + if (declaration.kind === 177 /* FunctionExpression */) { return true; } - if (declaration.kind !== 214 /* VariableDeclaration */ && declaration.kind !== 216 /* FunctionDeclaration */) { + if (declaration.kind !== 215 /* VariableDeclaration */ && declaration.kind !== 217 /* 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_10 = declaration.parent; !ts.isFunctionBlock(parent_10); parent_10 = parent_10.parent) { // Reached source file or module block - if (parent_9.kind === 251 /* SourceFile */ || parent_9.kind === 222 /* ModuleBlock */) { + if (parent_10.kind === 252 /* SourceFile */ || parent_10.kind === 223 /* ModuleBlock */) { return false; } } @@ -46575,7 +47982,6 @@ var ts; // Always default to "ScriptTarget.ES5" for the language service return { target: 1 /* ES5 */, - module: 0 /* None */, jsx: 1 /* Preserve */ }; } @@ -46604,12 +48010,14 @@ var ts; }; HostCache.prototype.createEntry = function (fileName, path) { var entry; + var scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : 0 /* Unknown */; var scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { entry = { hostFileName: fileName, version: this.host.getScriptVersion(fileName), - scriptSnapshot: scriptSnapshot + scriptSnapshot: scriptSnapshot, + scriptKind: scriptKind ? scriptKind : ts.getScriptKindFromFileName(fileName) }; } this.fileNameToEntry.set(path, entry); @@ -46657,11 +48065,12 @@ var ts; // The host does not know about this file. throw new Error("Could not find file: '" + fileName + "'."); } + var scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : 0 /* Unknown */; var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents*/ true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents*/ true, scriptKind); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -46695,6 +48104,8 @@ var ts; function transpileModule(input, transpileOptions) { var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; + // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. + options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; // We are not returning a sourceFile for lib file when asked by the program, @@ -46759,12 +48170,10 @@ var ts; return output.outputText; } ts.transpile = transpile; - function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { + function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) { var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); - var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents); + var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents, scriptKind); setSourceFileFields(sourceFile, scriptSnapshot, version); - // after full parsing we can use table with interned strings as name table - sourceFile.nameTable = sourceFile.identifiers; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; @@ -46776,7 +48185,7 @@ var ts; if (version !== sourceFile.version) { // Once incremental parsing is ready, then just call into this function. if (!ts.disableIncrementalParsing) { - var newText; + var newText = void 0; // grab the fragment from the beginning of the original text to the beginning of the span var prefix = textChangeRange.span.start !== 0 ? sourceFile.text.substr(0, textChangeRange.span.start) @@ -46816,7 +48225,7 @@ var ts; } } // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true); + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { @@ -46855,20 +48264,20 @@ var ts; }); return JSON.stringify(bucketInfoArray, undefined, 2); } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ true); + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ true, scriptKind); } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ false); + function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } - function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { + function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring, scriptKind) { var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var entry = bucket.get(path); 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, /*setNodeParents*/ false); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false, scriptKind); entry = { sourceFile: sourceFile, languageServiceRefCount: 0, @@ -46982,7 +48391,7 @@ var ts; else { if (token === 69 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -47013,7 +48422,7 @@ var ts; } if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -47029,7 +48438,7 @@ var ts; token = scanner.scan(); if (token === 69 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -47058,7 +48467,7 @@ var ts; } if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -47070,7 +48479,7 @@ var ts; } else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -47095,7 +48504,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? scanner.scan() : scanner.getToken(); - if (token === 127 /* RequireKeyword */) { + if (token === 128 /* RequireKeyword */) { token = scanner.scan(); if (token === 17 /* OpenParenToken */) { token = scanner.scan(); @@ -47189,7 +48598,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 210 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 211 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -47198,12 +48607,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 69 /* Identifier */ && - (node.parent.kind === 206 /* BreakStatement */ || node.parent.kind === 205 /* ContinueStatement */) && + (node.parent.kind === 207 /* BreakStatement */ || node.parent.kind === 206 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 69 /* Identifier */ && - node.parent.kind === 210 /* LabeledStatement */ && + node.parent.kind === 211 /* LabeledStatement */ && node.parent.label === node; } /** @@ -47211,7 +48620,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 210 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 211 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -47222,25 +48631,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 137 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 170 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 171 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 172 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 172 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 173 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 221 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 222 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 69 /* Identifier */ && @@ -47249,22 +48658,22 @@ var ts; /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 248 /* PropertyAssignment */ || node.parent.kind === 249 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 249 /* PropertyAssignment */ || node.parent.kind === 250 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 248 /* PropertyAssignment */: - case 250 /* EnumMember */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 221 /* ModuleDeclaration */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 249 /* PropertyAssignment */: + case 251 /* EnumMember */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 222 /* ModuleDeclaration */: return node.parent.name === node; - case 170 /* ElementAccessExpression */: + case 171 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -47323,7 +48732,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 135 /* LastKeyword */; i++) { + for (var i = 70 /* FirstKeyword */; i <= 136 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -47338,17 +48747,17 @@ var ts; return undefined; } switch (node.kind) { - case 251 /* SourceFile */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 221 /* ModuleDeclaration */: + case 252 /* SourceFile */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 222 /* ModuleDeclaration */: return node; } } @@ -47356,38 +48765,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 221 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 217 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 218 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 219 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 220 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 214 /* VariableDeclaration */: + case 222 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 218 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 219 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 220 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 221 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 215 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 216 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 146 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 147 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 217 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 147 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 148 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 150 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 149 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 148 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 145 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 138 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 250 /* EnumMember */: return ScriptElementKind.variableElement; - case 139 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 224 /* ImportEqualsDeclaration */: - case 229 /* ImportSpecifier */: - case 226 /* ImportClause */: - case 233 /* ExportSpecifier */: - case 227 /* NamespaceImport */: + case 151 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 150 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 149 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 146 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 139 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 251 /* EnumMember */: return ScriptElementKind.variableElement; + case 140 /* Parameter */: return (node.flags & 28 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 225 /* ImportEqualsDeclaration */: + case 230 /* ImportSpecifier */: + case 227 /* ImportClause */: + case 234 /* ExportSpecifier */: + case 228 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -47496,6 +48905,9 @@ var ts; return ts.directoryProbablyExists(directoryName, host); } }; + if (host.trace) { + compilerHost.trace = function (message) { return host.trace(message); }; + } if (host.resolveModuleNames) { compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; } @@ -47529,7 +48941,7 @@ var ts; return undefined; } // Check if the language version has changed since we last created a program; if they are the same, - // it is safe to reuse the souceFiles; if not, then the shape of the AST can change, and the oldSourceFile + // it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile // can not be reused. we have to dump all syntax trees and create new ones. if (!changesInCompilationSettingsAffectSyntax) { // Check if the old program had this file already @@ -47537,7 +48949,7 @@ var ts; if (oldSourceFile) { // 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: + // address the following race-condition. Specifically, say we have the following: // // LS1 // \ @@ -47556,11 +48968,15 @@ var ts; // 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 // host says should be used. - return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + // We do not support the scenario where a host can modify a registered + // file's script kind, i.e. in one project some file is treated as ".ts" + // and in another as ".js" + ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + fileName); + return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } } // Could not find this file in the old program, create a new SourceFile for it. - return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } function sourceFileUpToDate(sourceFile) { if (!sourceFile) { @@ -47610,7 +49026,7 @@ var ts; return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); } /** - * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors + * getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors * If '-d' enabled, report both semantic and emitter errors */ function getSemanticDiagnostics(fileName) { @@ -47699,9 +49115,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 272 /* JSDocTypeTag */: - case 270 /* JSDocParameterTag */: - case 271 /* JSDocReturnTag */: + case 273 /* JSDocTypeTag */: + case 271 /* JSDocParameterTag */: + case 272 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -47746,13 +49162,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; + var parent_11 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_10.kind === 169 /* PropertyAccessExpression */) { + if (parent_11.kind === 170 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 136 /* QualifiedName */) { + else if (parent_11.kind === 137 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -47767,7 +49183,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 240 /* JsxClosingElement */) { + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 241 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -47814,7 +49230,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */) { + if (node.kind === 69 /* Identifier */ || node.kind === 137 /* QualifiedName */ || node.kind === 170 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -47869,8 +49285,8 @@ var ts; return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { - var attrsType; - if ((jsxContainer.kind === 237 /* JsxSelfClosingElement */) || (jsxContainer.kind === 238 /* JsxOpeningElement */)) { + var attrsType = void 0; + if ((jsxContainer.kind === 238 /* JsxSelfClosingElement */) || (jsxContainer.kind === 239 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -47942,15 +49358,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 239 /* JsxText */) { + if (contextToken.kind === 240 /* JsxText */) { return true; } if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 238 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 239 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 240 /* JsxClosingElement */ || contextToken.parent.kind === 237 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 236 /* JsxElement */; + if (contextToken.parent.kind === 241 /* JsxClosingElement */ || contextToken.parent.kind === 238 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 237 /* JsxElement */; } } return false; @@ -47960,40 +49376,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 171 /* CallExpression */ // func( a, | - || containingNodeKind === 145 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 172 /* NewExpression */ // new C(a, | - || containingNodeKind === 167 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 184 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 153 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 172 /* CallExpression */ // func( a, | + || containingNodeKind === 146 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 173 /* NewExpression */ // new C(a, | + || containingNodeKind === 168 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 185 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 154 /* FunctionType */; // var x: (s: string, list| case 17 /* OpenParenToken */: - return containingNodeKind === 171 /* CallExpression */ // func( | - || containingNodeKind === 145 /* Constructor */ // constructor( | - || containingNodeKind === 172 /* NewExpression */ // new C(a| - || containingNodeKind === 175 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 161 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 172 /* CallExpression */ // func( | + || containingNodeKind === 146 /* Constructor */ // constructor( | + || containingNodeKind === 173 /* NewExpression */ // new C(a| + || containingNodeKind === 176 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 162 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 19 /* OpenBracketToken */: - return containingNodeKind === 167 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 150 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 137 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 168 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 151 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 138 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 125 /* ModuleKeyword */: // module | case 126 /* NamespaceKeyword */: return true; case 21 /* DotToken */: - return containingNodeKind === 221 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 222 /* ModuleDeclaration */; // module A.| case 15 /* OpenBraceToken */: - return containingNodeKind === 217 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 218 /* ClassDeclaration */; // class A{ | case 56 /* EqualsToken */: - return containingNodeKind === 214 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 184 /* BinaryExpression */; // x = a| + return containingNodeKind === 215 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 185 /* BinaryExpression */; // x = a| case 12 /* TemplateHead */: - return containingNodeKind === 186 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 187 /* TemplateExpression */; // `aa ${| case 13 /* TemplateMiddle */: - return containingNodeKind === 193 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 194 /* TemplateSpan */; // `aa ${10} dd ${| case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: - return containingNodeKind === 142 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 143 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -48007,7 +49423,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 163 /* StringLiteralType */ + || contextToken.kind === 164 /* StringLiteralType */ || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_7 = contextToken.getStart(); @@ -48037,14 +49453,14 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 168 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 169 /* 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 === 164 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 165 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -48090,9 +49506,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 228 /* NamedImports */ ? - 225 /* ImportDeclaration */ : - 231 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 229 /* NamedImports */ ? + 226 /* ImportDeclaration */ : + 232 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -48117,9 +49533,9 @@ var ts; switch (contextToken.kind) { case 15 /* OpenBraceToken */: // const x = { | case 24 /* CommaToken */: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 168 /* ObjectLiteralExpression */ || parent_11.kind === 164 /* ObjectBindingPattern */)) { - return parent_11; + var parent_12 = contextToken.parent; + if (parent_12 && (parent_12.kind === 169 /* ObjectLiteralExpression */ || parent_12.kind === 165 /* ObjectBindingPattern */)) { + return parent_12; } break; } @@ -48136,8 +49552,8 @@ var ts; case 15 /* OpenBraceToken */: // import { | case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 228 /* NamedImports */: - case 232 /* NamedExports */: + case 229 /* NamedImports */: + case 233 /* NamedExports */: return contextToken.parent; } } @@ -48146,37 +49562,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_13 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: case 39 /* SlashToken */: case 69 /* Identifier */: - case 241 /* JsxAttribute */: - case 242 /* JsxSpreadAttribute */: - if (parent_12 && (parent_12.kind === 237 /* JsxSelfClosingElement */ || parent_12.kind === 238 /* JsxOpeningElement */)) { - return parent_12; + case 242 /* JsxAttribute */: + case 243 /* JsxSpreadAttribute */: + if (parent_13 && (parent_13.kind === 238 /* JsxSelfClosingElement */ || parent_13.kind === 239 /* JsxOpeningElement */)) { + return parent_13; } - else if (parent_12.kind === 241 /* JsxAttribute */) { - return parent_12.parent; + else if (parent_13.kind === 242 /* JsxAttribute */) { + return parent_13.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_12 && ((parent_12.kind === 241 /* JsxAttribute */) || (parent_12.kind === 242 /* JsxSpreadAttribute */))) { - return parent_12.parent; + if (parent_13 && ((parent_13.kind === 242 /* JsxAttribute */) || (parent_13.kind === 243 /* JsxSpreadAttribute */))) { + return parent_13.parent; } break; case 16 /* CloseBraceToken */: - if (parent_12 && - parent_12.kind === 243 /* JsxExpression */ && - parent_12.parent && - (parent_12.parent.kind === 241 /* JsxAttribute */)) { - return parent_12.parent.parent; + if (parent_13 && + parent_13.kind === 244 /* JsxExpression */ && + parent_13.parent && + (parent_13.parent.kind === 242 /* JsxAttribute */)) { + return parent_13.parent.parent; } - if (parent_12 && parent_12.kind === 242 /* JsxSpreadAttribute */) { - return parent_12.parent; + if (parent_13 && parent_13.kind === 243 /* JsxSpreadAttribute */) { + return parent_13.parent; } break; } @@ -48185,16 +49601,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: return true; } return false; @@ -48206,66 +49622,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 214 /* VariableDeclaration */ || - containingNodeKind === 215 /* VariableDeclarationList */ || - containingNodeKind === 196 /* VariableStatement */ || - containingNodeKind === 220 /* EnumDeclaration */ || + return containingNodeKind === 215 /* VariableDeclaration */ || + containingNodeKind === 216 /* VariableDeclarationList */ || + containingNodeKind === 197 /* VariableStatement */ || + containingNodeKind === 221 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 217 /* ClassDeclaration */ || - containingNodeKind === 189 /* ClassExpression */ || - containingNodeKind === 218 /* InterfaceDeclaration */ || - containingNodeKind === 165 /* ArrayBindingPattern */ || - containingNodeKind === 219 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 218 /* ClassDeclaration */ || + containingNodeKind === 190 /* ClassExpression */ || + containingNodeKind === 219 /* InterfaceDeclaration */ || + containingNodeKind === 166 /* ArrayBindingPattern */ || + containingNodeKind === 220 /* TypeAliasDeclaration */; // type Map, K, | case 21 /* DotToken */: - return containingNodeKind === 165 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 166 /* ArrayBindingPattern */; // var [.| case 54 /* ColonToken */: - return containingNodeKind === 166 /* BindingElement */; // var {x :html| + return containingNodeKind === 167 /* BindingElement */; // var {x :html| case 19 /* OpenBracketToken */: - return containingNodeKind === 165 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 166 /* ArrayBindingPattern */; // var [x| case 17 /* OpenParenToken */: - return containingNodeKind === 247 /* CatchClause */ || + return containingNodeKind === 248 /* CatchClause */ || isFunction(containingNodeKind); case 15 /* OpenBraceToken */: - return containingNodeKind === 220 /* EnumDeclaration */ || - containingNodeKind === 218 /* InterfaceDeclaration */ || - containingNodeKind === 156 /* TypeLiteral */; // const x : { | + return containingNodeKind === 221 /* EnumDeclaration */ || + containingNodeKind === 219 /* InterfaceDeclaration */ || + containingNodeKind === 157 /* TypeLiteral */; // const x : { | case 23 /* SemicolonToken */: - return containingNodeKind === 141 /* PropertySignature */ && + return containingNodeKind === 142 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 218 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 156 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 219 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 157 /* TypeLiteral */); // const x : { a; | case 25 /* LessThanToken */: - return containingNodeKind === 217 /* ClassDeclaration */ || - containingNodeKind === 189 /* ClassExpression */ || - containingNodeKind === 218 /* InterfaceDeclaration */ || - containingNodeKind === 219 /* TypeAliasDeclaration */ || + return containingNodeKind === 218 /* ClassDeclaration */ || + containingNodeKind === 190 /* ClassExpression */ || + containingNodeKind === 219 /* InterfaceDeclaration */ || + containingNodeKind === 220 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 113 /* StaticKeyword */: - return containingNodeKind === 142 /* PropertyDeclaration */; + return containingNodeKind === 143 /* PropertyDeclaration */; case 22 /* DotDotDotToken */: - return containingNodeKind === 139 /* Parameter */ || + return containingNodeKind === 140 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 165 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 166 /* ArrayBindingPattern */); // var [...z| case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: - return containingNodeKind === 139 /* Parameter */; + return containingNodeKind === 140 /* Parameter */; case 116 /* AsKeyword */: - return containingNodeKind === 229 /* ImportSpecifier */ || - containingNodeKind === 233 /* ExportSpecifier */ || - containingNodeKind === 227 /* NamespaceImport */; + return containingNodeKind === 230 /* ImportSpecifier */ || + containingNodeKind === 234 /* ExportSpecifier */ || + containingNodeKind === 228 /* NamespaceImport */; case 73 /* ClassKeyword */: case 81 /* EnumKeyword */: case 107 /* InterfaceKeyword */: case 87 /* FunctionKeyword */: case 102 /* VarKeyword */: case 123 /* GetKeyword */: - case 129 /* SetKeyword */: + case 130 /* SetKeyword */: case 89 /* ImportKeyword */: case 108 /* LetKeyword */: case 74 /* ConstKeyword */: case 114 /* YieldKeyword */: - case 132 /* TypeKeyword */: + case 133 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -48306,7 +49722,7 @@ var ts; * do not occur at the current position and have not otherwise been typed. */ function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { - var exisingImportsOrExports = {}; + var existingImportsOrExports = {}; for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { var element = namedImportsOrExports_1[_i]; // If this is the current item we are editing right now, do not filter it out @@ -48314,12 +49730,12 @@ var ts; continue; } var name_34 = element.propertyName || element.name; - exisingImportsOrExports[name_34.text] = true; + existingImportsOrExports[name_34.text] = true; } - if (ts.isEmpty(exisingImportsOrExports)) { + if (ts.isEmpty(existingImportsOrExports)) { return exportsOfModule; } - return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); + return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(existingImportsOrExports, e.name); }); } /** * Filters out completion suggestions for named imports or exports. @@ -48335,10 +49751,10 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 248 /* PropertyAssignment */ && - m.kind !== 249 /* ShorthandPropertyAssignment */ && - m.kind !== 166 /* BindingElement */ && - m.kind !== 144 /* MethodDeclaration */) { + if (m.kind !== 249 /* PropertyAssignment */ && + m.kind !== 250 /* ShorthandPropertyAssignment */ && + m.kind !== 167 /* BindingElement */ && + m.kind !== 145 /* MethodDeclaration */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -48346,7 +49762,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 166 /* BindingElement */ && m.propertyName) { + if (m.kind === 167 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 69 /* Identifier */) { existingName = m.propertyName.text; @@ -48376,7 +49792,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 241 /* JsxAttribute */) { + if (attr.kind === 242 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -48389,21 +49805,21 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; 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() }; } var sourceFile = getValidSourceFile(fileName); var entries = []; - if (isRightOfDot && ts.isSourceFileJavaScript(sourceFile)) { + if (ts.isSourceFileJavaScript(sourceFile)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 240 /* JsxClosingElement */) { + location.parent && location.parent.kind === 241 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -48427,11 +49843,15 @@ var ts; ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, uniqueNames) { + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var target = program.getCompilerOptions().target; var nameTable = getNameTable(sourceFile); for (var name_35 in nameTable) { + // Skip identifiers produced only from the current location + if (nameTable[name_35] === position) { + continue; + } if (!uniqueNames[name_35]) { uniqueNames[name_35] = name_35; var displayName = getCompletionEntryDisplayName(name_35, target, /*performCharacterChecks*/ true); @@ -48484,8 +49904,8 @@ var ts; var start = new Date().getTime(); var uniqueNames = {}; if (symbols) { - for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { - var symbol = symbols_3[_i]; + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); @@ -48507,11 +49927,11 @@ var ts; if (completionData) { var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. - var target = program.getCompilerOptions().target; + var target_2 = 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 // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks*/ false, location_2) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target_2, /*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 { @@ -48540,7 +49960,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 189 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 190 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -48639,10 +50059,10 @@ var ts; if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { symbolKind = ScriptElementKind.memberVariableElement; } - var signature; + var signature = void 0; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 169 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 170 /* 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)) { @@ -48650,8 +50070,8 @@ var ts; } } // try get the call/construct signature from the type if it matches - var callExpression; - if (location.kind === 171 /* CallExpression */ || location.kind === 172 /* NewExpression */) { + var callExpression = void 0; + if (location.kind === 172 /* CallExpression */ || location.kind === 173 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -48664,7 +50084,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 172 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 173 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -48717,24 +50137,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 145 /* Constructor */)) { + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 146 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 145 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 146 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 145 /* Constructor */) { + if (functionDeclaration.kind === 146 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 148 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 149 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -48743,7 +50163,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 189 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 190 /* 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 @@ -48766,7 +50186,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(133 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -48787,7 +50207,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 221 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 222 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -48810,17 +50230,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 138 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 139 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 149 /* ConstructSignature */) { + if (declaration.kind === 150 /* ConstructSignature */) { displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 148 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 149 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -48829,7 +50249,7 @@ var ts; // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(133 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -48840,7 +50260,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 250 /* EnumMember */) { + if (declaration.kind === 251 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -48856,13 +50276,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 224 /* ImportEqualsDeclaration */) { + if (declaration.kind === 225 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(128 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); @@ -48989,10 +50409,10 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 69 /* Identifier */: - case 169 /* PropertyAccessExpression */: - case 136 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: + case 137 /* QualifiedName */: case 97 /* ThisKeyword */: - case 162 /* ThisType */: + case 163 /* ThisType */: case 95 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -49071,8 +50491,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 145 /* Constructor */) || - (!selectConstructors && (d.kind === 216 /* FunctionDeclaration */ || d.kind === 144 /* MethodDeclaration */ || d.kind === 143 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 146 /* Constructor */) || + (!selectConstructors && (d.kind === 217 /* FunctionDeclaration */ || d.kind === 145 /* MethodDeclaration */ || d.kind === 144 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -49132,7 +50552,14 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 69 /* Identifier */ && node.parent === declaration) { + // Go to the original declaration for cases: + // + // (1) when the aliased symbol was declared in the location(parent). + // (2) when the aliased symbol is originating from a named import. + // + if (node.kind === 69 /* Identifier */ && + (node.parent === declaration || + (declaration.kind === 230 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 229 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -49141,16 +50568,16 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 249 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 250 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; } var shorthandDeclarations = shorthandSymbol.getDeclarations(); - var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node); - var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol); - var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); - return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); + var shorthandSymbolKind_1 = getSymbolKind(shorthandSymbol, node); + var shorthandSymbolName_1 = typeChecker.symbolToString(shorthandSymbol); + var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } return getDefinitionFromSymbol(symbol, node); } @@ -49172,13 +50599,13 @@ var ts; return undefined; } if (type.flags & 16384 /* Union */) { - var result = []; + var result_3 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(/*to*/ result_3, /*from*/ getDefinitionFromSymbol(t.symbol, node)); } }); - return result; + return result_3; } if (!type.symbol) { return undefined; @@ -49188,10 +50615,10 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); + var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); // 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; }); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); } return results; } @@ -49217,7 +50644,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || - node.kind === 162 /* ThisType */ || + node.kind === 163 /* ThisType */ || node.kind === 95 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { @@ -49271,75 +50698,75 @@ var ts; switch (node.kind) { case 88 /* IfKeyword */: case 80 /* ElseKeyword */: - if (hasKind(node.parent, 199 /* IfStatement */)) { + if (hasKind(node.parent, 200 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 207 /* ReturnStatement */)) { + if (hasKind(node.parent, 208 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 211 /* ThrowStatement */)) { + if (hasKind(node.parent, 212 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 212 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 213 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 100 /* TryKeyword */: case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 212 /* TryStatement */)) { + if (hasKind(parent(node), 213 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 209 /* SwitchStatement */)) { + if (hasKind(node.parent, 210 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 71 /* CaseKeyword */: case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 209 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 210 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 70 /* BreakKeyword */: case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 206 /* BreakStatement */) || hasKind(node.parent, 205 /* ContinueStatement */)) { + if (hasKind(node.parent, 207 /* BreakStatement */) || hasKind(node.parent, 206 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 86 /* ForKeyword */: - if (hasKind(node.parent, 202 /* ForStatement */) || - hasKind(node.parent, 203 /* ForInStatement */) || - hasKind(node.parent, 204 /* ForOfStatement */)) { + if (hasKind(node.parent, 203 /* ForStatement */) || + hasKind(node.parent, 204 /* ForInStatement */) || + hasKind(node.parent, 205 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 104 /* WhileKeyword */: case 79 /* DoKeyword */: - if (hasKind(node.parent, 201 /* WhileStatement */) || hasKind(node.parent, 200 /* DoStatement */)) { + if (hasKind(node.parent, 202 /* WhileStatement */) || hasKind(node.parent, 201 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 145 /* Constructor */)) { + if (hasKind(node.parent, 146 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 123 /* GetKeyword */: - case 129 /* SetKeyword */: - if (hasKind(node.parent, 146 /* GetAccessor */) || hasKind(node.parent, 147 /* SetAccessor */)) { + case 130 /* SetKeyword */: + if (hasKind(node.parent, 147 /* GetAccessor */) || hasKind(node.parent, 148 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 196 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 197 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -49355,10 +50782,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 /* ThrowStatement */) { + if (node.kind === 212 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 212 /* TryStatement */) { + else if (node.kind === 213 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -49385,19 +50812,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 === 251 /* SourceFile */) { - return parent_13; + var parent_14 = child.parent; + if (ts.isFunctionBlock(parent_14) || parent_14.kind === 252 /* SourceFile */) { + return parent_14; } // 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 === 212 /* TryStatement */) { - var tryStatement = parent_13; + if (parent_14.kind === 213 /* TryStatement */) { + var tryStatement = parent_14; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_14; } return undefined; } @@ -49406,7 +50833,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206 /* BreakStatement */ || node.kind === 205 /* ContinueStatement */) { + if (node.kind === 207 /* BreakStatement */ || node.kind === 206 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -49421,16 +50848,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 209 /* SwitchStatement */: - if (statement.kind === 205 /* ContinueStatement */) { + case 210 /* SwitchStatement */: + if (statement.kind === 206 /* ContinueStatement */) { continue; } // Fall through. - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 201 /* WhileStatement */: - case 200 /* DoStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 202 /* WhileStatement */: + case 201 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -49449,24 +50876,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 === 217 /* ClassDeclaration */ || - container.kind === 189 /* ClassExpression */ || - (declaration.kind === 139 /* Parameter */ && hasKind(container, 145 /* Constructor */)))) { + if (!(container.kind === 218 /* ClassDeclaration */ || + container.kind === 190 /* ClassExpression */ || + (declaration.kind === 140 /* Parameter */ && hasKind(container, 146 /* Constructor */)))) { return undefined; } } else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 217 /* ClassDeclaration */ || container.kind === 189 /* ClassExpression */)) { + if (!(container.kind === 218 /* ClassDeclaration */ || container.kind === 190 /* ClassExpression */)) { return undefined; } } else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 222 /* ModuleBlock */ || container.kind === 251 /* SourceFile */)) { + if (!(container.kind === 223 /* ModuleBlock */ || container.kind === 252 /* SourceFile */)) { return undefined; } } else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 217 /* ClassDeclaration */ || declaration.kind === 217 /* ClassDeclaration */)) { + if (!(container.kind === 218 /* ClassDeclaration */ || declaration.kind === 218 /* ClassDeclaration */)) { return undefined; } } @@ -49478,8 +50905,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 222 /* ModuleBlock */: - case 251 /* SourceFile */: + case 223 /* ModuleBlock */: + case 252 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -49488,17 +50915,17 @@ var ts; nodes = container.statements; } break; - case 145 /* Constructor */: + case 146 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 56 /* AccessibilityModifier */) { + if (modifierFlag & 28 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 145 /* Constructor */ && member; + return member.kind === 146 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -49520,17 +50947,17 @@ var ts; function getFlagFromModifier(modifier) { switch (modifier) { case 112 /* PublicKeyword */: - return 8 /* Public */; + return 4 /* Public */; case 110 /* PrivateKeyword */: - return 16 /* Private */; + return 8 /* Private */; case 111 /* ProtectedKeyword */: - return 32 /* Protected */; + return 16 /* Protected */; case 113 /* StaticKeyword */: - return 64 /* Static */; + return 32 /* Static */; case 82 /* ExportKeyword */: - return 2 /* Export */; + return 1 /* Export */; case 122 /* DeclareKeyword */: - return 4 /* Ambient */; + return 2 /* Ambient */; case 115 /* AbstractKeyword */: return 128 /* Abstract */; default: @@ -49551,13 +50978,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 147 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 147 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 148 /* 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, 123 /* GetKeyword */, 129 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 130 /* SetKeyword */); }); } } } @@ -49575,7 +51002,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 200 /* DoStatement */) { + if (loopNode.kind === 201 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { @@ -49596,13 +51023,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -49656,7 +51083,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 195 /* Block */))) { + if (!(func && hasKind(func.body, 196 /* Block */))) { return undefined; } var keywords = []; @@ -49672,7 +51099,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 199 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 200 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -49685,7 +51112,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 199 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 200 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -49802,7 +51229,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 /* ThisKeyword */ || node.kind === 162 /* ThisType */) { + if (node.kind === 97 /* ThisKeyword */ || node.kind === 163 /* ThisType */) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95 /* SuperKeyword */) { @@ -49840,7 +51267,7 @@ var ts; var sourceFile = sourceFiles_3[_i]; cancellationToken.throwIfCancellationRequested(); var nameTable = getNameTable(sourceFile); - if (ts.lookUp(nameTable, internedName)) { + if (ts.lookUp(nameTable, internedName) !== undefined) { result = result || []; getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } @@ -49864,7 +51291,7 @@ var ts; }; } function isImportSpecifierSymbol(symbol) { - return (symbol.flags & 8388608 /* Alias */) && !!ts.getDeclarationOfKind(symbol, 229 /* ImportSpecifier */); + return (symbol.flags & 8388608 /* Alias */) && !!ts.getDeclarationOfKind(symbol, 230 /* ImportSpecifier */); } function getInternedName(symbol, location, declarations) { // If this is an export or import specifier it could have been renamed using the 'as' syntax. @@ -49890,18 +51317,18 @@ 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 === 176 /* FunctionExpression */ || valueDeclaration.kind === 189 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 177 /* FunctionExpression */ || valueDeclaration.kind === 190 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16 /* Private */) ? d : undefined; }); + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 217 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 218 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visibile outside its declaration scope. + // So consider it visible outside its declaration scope. if (symbol.flags & 8388608 /* Alias */) { return undefined; } @@ -49913,8 +51340,8 @@ var ts; var scope; var declarations = symbol.getDeclarations(); if (declarations) { - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; @@ -49923,7 +51350,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 251 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 252 /* 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; @@ -50022,7 +51449,7 @@ var ts; var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, container.getStart(), container.getEnd()); if (possiblePositions.length) { // Build the set of symbols to search for, initially it has only the current symbol - var searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation); + var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); @@ -50054,12 +51481,12 @@ var ts; if (referenceSymbol) { var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); + var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation); if (relatedSymbol) { var referencedSymbol = getReferencedSymbol(relatedSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation)); } - else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { + else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } @@ -50094,15 +51521,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 64 /* Static */; + var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -50122,7 +51549,7 @@ var ts; // 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. - if (container && (64 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + if (container && (32 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { references.push(getReferenceEntryFromNode(node)); } }); @@ -50132,29 +51559,29 @@ var ts; function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 64 /* Static */; + var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 177 /* 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. @@ -50163,7 +51590,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 251 /* SourceFile */) { + if (searchSpaceNode.kind === 252 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -50189,33 +51616,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 162 /* ThisType */)) { + if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 163 /* ThisType */)) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 189 /* ClassExpression */: - case 217 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 218 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64 /* Static */) === staticFlag) { + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 32 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 251 /* SourceFile */: - if (container.kind === 251 /* SourceFile */ && !ts.isExternalModule(container)) { + case 252 /* SourceFile */: + if (container.kind === 252 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -50226,16 +51653,16 @@ var ts; function populateSearchSymbolSet(symbol, location) { // The search set contains at least the current symbol var result = [symbol]; - // If the symbol is an alias, add what it alaises to the list + // If the symbol is an alias, add what it aliases to the list if (isImportSpecifierSymbol(symbol)) { result.push(typeChecker.getAliasedSymbol(symbol)); } - // For export specifiers, the exported name can be refering to a local symbol, e.g.: + // For export specifiers, the exported name can be referring to a local symbol, e.g.: // import {a} from "mod"; // export {a as somethingElse} // We want the *local* declaration of 'a' as declared in the import, // *not* as declared within "mod" (or farther) - if (location.parent.kind === 233 /* ExportSpecifier */) { + if (location.parent.kind === 234 /* ExportSpecifier */) { result.push(typeChecker.getExportSpecifierLocalTargetSymbol(location.parent)); } // If the location is in a context sensitive location (i.e. in an object literal) try @@ -50263,9 +51690,9 @@ var ts; } // If the symbol.valueDeclaration is a property parameter declaration, // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in contructor.locals. + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 139 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 140 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -50285,9 +51712,9 @@ var ts; /** * Find symbol of the given property-name and add the symbol to the given result array * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to serach for + * @param propertyName a name of property to search for * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisitng of the same symbol. + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. * The value of previousIterationSymbol is undefined when the function is first called. */ function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { @@ -50310,11 +51737,11 @@ var ts; } if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 217 /* ClassDeclaration */) { + if (declaration.kind === 218 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 218 /* InterfaceDeclaration */) { + else if (declaration.kind === 219 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -50351,7 +51778,7 @@ var ts; // import {a} from "mod"; // export {a as somethingElse} // We want the local target of the export (i.e. the import symbol) and not the final target (i.e. "mod".a) - if (referenceLocation.parent.kind === 233 /* ExportSpecifier */) { + if (referenceLocation.parent.kind === 234 /* ExportSpecifier */) { var aliasedSymbol = typeChecker.getExportSpecifierLocalTargetSymbol(referenceLocation.parent); if (searchSymbols.indexOf(aliasedSymbol) >= 0) { return aliasedSymbol; @@ -50375,9 +51802,9 @@ var ts; // 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 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3, /*previousIterationSymbolsCache*/ {}); - return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + var result_4 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, /*previousIterationSymbolsCache*/ {}); + return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } return undefined; }); @@ -50396,14 +51823,14 @@ var ts; return [unionProperty]; } else { - var result_4 = []; + var result_5 = []; ts.forEach(contextualType.types, function (t) { var symbol = t.getProperty(name_36); if (symbol) { - result_4.push(symbol); + result_5.push(symbol); } }); - return result_4; + return result_5; } } else { @@ -50425,7 +51852,7 @@ var ts; */ function getIntersectingMeaningFromDeclarations(meaning, declarations) { if (declarations) { - var lastIterationMeaning; + var lastIterationMeaning = void 0; do { // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module @@ -50433,8 +51860,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; var declarationMeaning = getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -50465,10 +51892,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 183 /* PostfixUnaryExpression */ || parent.kind === 182 /* PrefixUnaryExpression */) { + if (parent.kind === 184 /* PostfixUnaryExpression */ || parent.kind === 183 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 184 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 185 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; } @@ -50499,33 +51926,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 139 /* Parameter */: - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 248 /* PropertyAssignment */: - case 249 /* ShorthandPropertyAssignment */: - case 250 /* EnumMember */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 247 /* CatchClause */: + case 140 /* Parameter */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 249 /* PropertyAssignment */: + case 250 /* ShorthandPropertyAssignment */: + case 251 /* EnumMember */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 248 /* CatchClause */: return 1 /* Value */; - case 138 /* TypeParameter */: - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 156 /* TypeLiteral */: + case 139 /* TypeParameter */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 157 /* TypeLiteral */: return 2 /* Type */; - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -50535,15 +51962,15 @@ var ts; else { return 4 /* Namespace */; } - case 228 /* NamedImports */: - case 229 /* ImportSpecifier */: - case 224 /* ImportEqualsDeclaration */: - case 225 /* ImportDeclaration */: - case 230 /* ExportAssignment */: - case 231 /* ExportDeclaration */: + case 229 /* NamedImports */: + case 230 /* ImportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 226 /* ImportDeclaration */: + case 231 /* ExportAssignment */: + case 232 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 251 /* SourceFile */: + case 252 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -50552,10 +51979,10 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 152 /* TypeReference */ || - (node.parent.kind === 191 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 153 /* TypeReference */ || + (node.parent.kind === 192 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node)) || - node.kind === 162 /* ThisType */; + node.kind === 163 /* ThisType */; } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -50563,32 +51990,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 169 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 169 /* PropertyAccessExpression */) { + if (root.parent.kind === 170 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 170 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 191 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 246 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 192 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 247 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 217 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 218 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + return (decl.kind === 218 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 219 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 136 /* QualifiedName */) { - while (root.parent && root.parent.kind === 136 /* QualifiedName */) { + if (root.parent.kind === 137 /* QualifiedName */) { + while (root.parent && root.parent.kind === 137 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 152 /* TypeReference */ && !isLastClause; + return root.parent.kind === 153 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 136 /* QualifiedName */) { + while (node.parent.kind === 137 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -50598,15 +52025,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 136 /* QualifiedName */ && + if (node.parent.kind === 137 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 224 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 225 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 230 /* ExportAssignment */) { + if (node.parent.kind === 231 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -50646,16 +52073,16 @@ var ts; return; } switch (node.kind) { - case 169 /* PropertyAccessExpression */: - case 136 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: + case 137 /* QualifiedName */: case 9 /* StringLiteral */: - case 163 /* StringLiteralType */: + case 164 /* StringLiteralType */: case 84 /* FalseKeyword */: case 99 /* TrueKeyword */: case 93 /* NullKeyword */: case 95 /* SuperKeyword */: case 97 /* ThisKeyword */: - case 162 /* ThisType */: + case 163 /* ThisType */: case 69 /* Identifier */: break; // Cant create the text span @@ -50672,7 +52099,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 221 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 222 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -50713,10 +52140,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 221 /* ModuleDeclaration */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: + case 222 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -50770,7 +52197,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 221 /* ModuleDeclaration */ && + return declaration.kind === 222 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -50931,16 +52358,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 270 /* JSDocParameterTag */: + case 271 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 273 /* JSDocTemplateTag */: + case 274 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 272 /* JSDocTypeTag */: + case 273 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 271 /* JSDocReturnTag */: + case 272 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -50998,19 +52425,53 @@ var ts; pushClassification(start, end - start, type); } } - function classifyTokenOrJsxText(token) { - if (ts.nodeIsMissing(token)) { - return; + /** + * Returns true if node should be treated as classified and no further processing is required. + * False will mean that node is not classified and traverse routine should recurse into node contents. + */ + function tryClassifyNode(node) { + if (ts.nodeIsMissing(node)) { + return true; } - var tokenStart = token.kind === 239 /* JsxText */ ? token.pos : classifyLeadingTriviaAndGetTokenStart(token); - var tokenWidth = token.end - tokenStart; + var classifiedElementName = tryClassifyJsxElementName(node); + if (!ts.isToken(node) && node.kind !== 240 /* JsxText */ && classifiedElementName === undefined) { + return false; + } + var tokenStart = node.kind === 240 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { - var type = classifyTokenType(token.kind, token); + var type = classifiedElementName || classifyTokenType(node.kind, node); if (type) { pushClassification(tokenStart, tokenWidth, type); } } + return true; + } + function tryClassifyJsxElementName(token) { + switch (token.parent && token.parent.kind) { + case 239 /* JsxOpeningElement */: + if (token.parent.tagName === token) { + return 19 /* jsxOpenTagName */; + } + break; + case 241 /* JsxClosingElement */: + if (token.parent.tagName === token) { + return 20 /* jsxCloseTagName */; + } + break; + case 238 /* JsxSelfClosingElement */: + if (token.parent.tagName === token) { + return 21 /* jsxSelfClosingTagName */; + } + break; + case 242 /* JsxAttribute */: + if (token.parent.name === token) { + return 22 /* jsxAttribute */; + } + break; + } + return undefined; } // 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 @@ -51032,17 +52493,17 @@ var ts; if (token) { if (tokenKind === 56 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 214 /* VariableDeclaration */ || - token.parent.kind === 142 /* PropertyDeclaration */ || - token.parent.kind === 139 /* Parameter */ || - token.parent.kind === 241 /* JsxAttribute */) { + if (token.parent.kind === 215 /* VariableDeclaration */ || + token.parent.kind === 143 /* PropertyDeclaration */ || + token.parent.kind === 140 /* Parameter */ || + token.parent.kind === 242 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 184 /* BinaryExpression */ || - token.parent.kind === 182 /* PrefixUnaryExpression */ || - token.parent.kind === 183 /* PostfixUnaryExpression */ || - token.parent.kind === 185 /* ConditionalExpression */) { + if (token.parent.kind === 185 /* BinaryExpression */ || + token.parent.kind === 183 /* PrefixUnaryExpression */ || + token.parent.kind === 184 /* PostfixUnaryExpression */ || + token.parent.kind === 186 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -51051,8 +52512,8 @@ var ts; else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 9 /* StringLiteral */ || tokenKind === 163 /* StringLiteralType */) { - return token.parent.kind === 241 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 9 /* StringLiteral */ || tokenKind === 164 /* StringLiteralType */) { + return token.parent.kind === 242 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -51062,61 +52523,42 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 239 /* JsxText */) { + else if (tokenKind === 240 /* JsxText */) { return 23 /* jsxText */; } else if (tokenKind === 69 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 139 /* Parameter */: + case 140 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } return; - case 238 /* JsxOpeningElement */: - if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; - } - return; - case 240 /* JsxClosingElement */: - if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; - } - return; - case 237 /* JsxSelfClosingElement */: - if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; - } - return; - case 241 /* JsxAttribute */: - if (token.parent.name === token) { - return 22 /* jsxAttribute */; - } } } return 2 /* identifier */; @@ -51132,10 +52574,7 @@ var ts; var children = element.getChildren(sourceFile); for (var i = 0, n = children.length; i < n; i++) { var child = children[i]; - if (ts.isToken(child) || child.kind === 239 /* JsxText */) { - classifyTokenOrJsxText(child); - } - else { + if (!tryClassifyNode(child)) { // Recurse into our child nodes. processElement(child); } @@ -51259,19 +52698,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 145 /* Constructor */: - case 217 /* ClassDeclaration */: - case 196 /* VariableStatement */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 146 /* Constructor */: + case 218 /* ClassDeclaration */: + case 197 /* VariableStatement */: break findOwner; - case 251 /* SourceFile */: + case 252 /* SourceFile */: return undefined; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 221 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 222 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -51284,8 +52723,7 @@ var ts; 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 newLine = ts.getNewLineOrDefaultFromHost(host); var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; @@ -51313,7 +52751,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 196 /* VariableStatement */) { + if (commentOwner.kind === 197 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -51331,17 +52769,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 175 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 176 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return rightHandSide.parameters; - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 145 /* Constructor */) { + if (member.kind === 146 /* Constructor */) { return member.parameters; } } @@ -51363,7 +52801,7 @@ var ts; var result = []; if (descriptors.length > 0) { var regExp = getTodoCommentsRegExp(); - var matchArray; + var matchArray = void 0; while (matchArray = regExp.exec(fileContents)) { cancellationToken.throwIfCancellationRequested(); // If we got a match, here is what the match array will look like. Say the source text is: @@ -51434,11 +52872,11 @@ var ts; // comment portion. var singleLineCommentStart = /(?:\/\/+\s*)/.source; var multiLineCommentStart = /(?:\/\*+\s*)/.source; - var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; + var anyNumberOfSpacesAndAsterisksAtStartOfLine = /(?:^(?:\s|\*)*)/.source; // Match any of the above three TODO comment start regexps. // Note that the outermost group *is* a capture group. We want to capture the preamble // so that we can determine the starting position of the TODO comment match. - var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + var preamble = "(" + anyNumberOfSpacesAndAsterisksAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; // Takes the descriptors and forms a regexp that matches them as if they were literals. // For example, if the descriptors are "TODO(jason)" and "HACK", then this will be: // @@ -51489,14 +52927,14 @@ var ts; var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); if (defaultLibFileName) { - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var current = declarations_10[_i]; - var sourceFile_2 = current.getSourceFile(); + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var current = declarations_11[_i]; + var sourceFile_3 = current.getSourceFile(); // TODO (drosen): When is there no source file? - if (!sourceFile_2) { + if (!sourceFile_3) { continue; } - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_3.fileName)); if (canonicalName === canonicalDefaultLibName) { return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); } @@ -51586,7 +53024,7 @@ var ts; function walk(node) { switch (node.kind) { case 69 /* Identifier */: - nameTable[node.text] = node.text; + nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -51595,9 +53033,9 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 235 /* ExternalModuleReference */ || + node.parent.kind === 236 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { - nameTable[node.text] = node.text; + nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; } break; default: @@ -51608,7 +53046,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 170 /* ElementAccessExpression */ && + node.parent.kind === 171 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -51656,7 +53094,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 123 /* GetKeyword */ || - keyword2 === 129 /* SetKeyword */ || + keyword2 === 130 /* SetKeyword */ || keyword2 === 121 /* ConstructorKeyword */ || keyword2 === 113 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -51815,10 +53253,10 @@ var ts; angleBracketStack--; } else if (token === 117 /* AnyKeyword */ || - token === 130 /* StringKeyword */ || - token === 128 /* NumberKeyword */ || + token === 131 /* StringKeyword */ || + token === 129 /* NumberKeyword */ || token === 120 /* BooleanKeyword */ || - token === 131 /* SymbolKeyword */) { + token === 132 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -51867,7 +53305,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 9 /* StringLiteral */ || token === 163 /* StringLiteralType */) { + if (token === 9 /* StringLiteral */ || token === 164 /* StringLiteralType */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -51990,7 +53428,7 @@ var ts; } } function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 135 /* LastKeyword */; + return token >= 70 /* FirstKeyword */ && token <= 136 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -52006,7 +53444,7 @@ var ts; case 8 /* NumericLiteral */: return 4 /* numericLiteral */; case 9 /* StringLiteral */: - case 163 /* StringLiteralType */: + case 164 /* StringLiteralType */: return 6 /* stringLiteral */; case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; @@ -52068,7 +53506,7 @@ var ts; */ function spanInSourceFileAtLocation(sourceFile, position) { // Cannot set breakpoint in dts file - if (sourceFile.flags & 4096 /* DeclarationFile */) { + if (sourceFile.isDeclarationFile) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -52118,113 +53556,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 214 /* VariableDeclaration */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 215 /* VariableDeclaration */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return spanInVariableDeclaration(node); - case 139 /* Parameter */: + case 140 /* Parameter */: return spanInParameterDeclaration(node); - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 145 /* Constructor */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 146 /* Constructor */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 195 /* Block */: + case 196 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 222 /* ModuleBlock */: + case 223 /* ModuleBlock */: return spanInBlock(node); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return spanInBlock(node.block); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 200 /* DoStatement */: + case 201 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 213 /* DebuggerStatement */: + case 214 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 199 /* IfStatement */: + case 200 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 206 /* BreakStatement */: - case 205 /* ContinueStatement */: + case 207 /* BreakStatement */: + case 206 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 202 /* ForStatement */: + case 203 /* ForStatement */: return spanInForStatement(node); - case 203 /* ForInStatement */: + case 204 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 204 /* ForOfStatement */: + case 205 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* CaseClause */: - case 245 /* DefaultClause */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 212 /* TryStatement */: + case 213 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 211 /* ThrowStatement */: + case 212 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 250 /* EnumMember */: - case 166 /* BindingElement */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 251 /* EnumMember */: + case 167 /* BindingElement */: // span on complete node return textSpan(node); - case 208 /* WithStatement */: + case 209 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 140 /* Decorator */: + case 141 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: return undefined; // Tokens: case 23 /* SemicolonToken */: @@ -52254,7 +53692,7 @@ var ts; case 72 /* CatchKeyword */: case 85 /* FinallyKeyword */: return spanInNextNode(node); - case 135 /* OfKeyword */: + case 136 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -52267,13 +53705,13 @@ var ts; // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 69 /* Identifier */ || - node.kind == 188 /* SpreadElementExpression */ || - node.kind === 248 /* PropertyAssignment */ || - node.kind === 249 /* ShorthandPropertyAssignment */) && + node.kind == 189 /* SpreadElementExpression */ || + node.kind === 249 /* PropertyAssignment */ || + node.kind === 250 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 184 /* BinaryExpression */) { + if (node.kind === 185 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -52296,22 +53734,22 @@ var ts; } if (ts.isExpression(node)) { switch (node.parent.kind) { - case 200 /* DoStatement */: + case 201 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 140 /* Decorator */: + case 141 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 202 /* ForStatement */: - case 204 /* ForOfStatement */: + case 203 /* ForStatement */: + case 205 /* ForOfStatement */: return textSpan(node); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: if (node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 177 /* ArrowFunction */: + case 178 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -52320,13 +53758,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 248 /* PropertyAssignment */ && + if (node.parent.kind === 249 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 174 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 175 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -52334,8 +53772,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 214 /* VariableDeclaration */ || - node.parent.kind === 139 /* Parameter */)) { + if ((node.parent.kind === 215 /* VariableDeclaration */ || + node.parent.kind === 140 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -52343,7 +53781,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 184 /* BinaryExpression */) { + if (node.parent.kind === 185 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -52369,7 +53807,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 203 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 204 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern set breakpoint in binding pattern @@ -52379,8 +53817,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if (variableDeclaration.initializer || - (variableDeclaration.flags & 2 /* Export */) || - variableDeclaration.parent.parent.kind === 204 /* ForOfStatement */) { + (variableDeclaration.flags & 1 /* Export */) || + variableDeclaration.parent.parent.kind === 205 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -52395,7 +53833,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */); + !!(parameter.flags & 4 /* Public */) || !!(parameter.flags & 8 /* Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -52419,8 +53857,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 2 /* Export */) || - (functionDeclaration.parent.kind === 217 /* ClassDeclaration */ && functionDeclaration.kind !== 145 /* Constructor */); + return !!(functionDeclaration.flags & 1 /* Export */) || + (functionDeclaration.parent.kind === 218 /* ClassDeclaration */ && functionDeclaration.kind !== 146 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -52443,25 +53881,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 201 /* WhileStatement */: - case 199 /* IfStatement */: - case 203 /* ForInStatement */: + case 202 /* WhileStatement */: + case 200 /* IfStatement */: + case 204 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 202 /* ForStatement */: - case 204 /* ForOfStatement */: + case 203 /* ForStatement */: + case 205 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStaement) { - if (forLikeStaement.initializer.kind === 215 /* VariableDeclarationList */) { + if (forLikeStaement.initializer.kind === 216 /* VariableDeclarationList */) { // declaration list, set breakpoint in first declaration var variableDeclarationList = forLikeStaement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -52486,23 +53924,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 191 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 166 /* BindingElement */) { + if (bindingPattern.parent.kind === 167 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 165 /* ArrayBindingPattern */ && node.kind !== 164 /* ObjectBindingPattern */); - var elements = node.kind === 167 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 166 /* ArrayBindingPattern */ && node.kind !== 165 /* ObjectBindingPattern */); + var elements = node.kind === 168 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 191 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -52510,18 +53948,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 184 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 185 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 223 /* CaseBlock */: + case 224 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -52529,24 +53967,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 222 /* ModuleBlock */: + case 223 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 220 /* EnumDeclaration */: - case 217 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 218 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 195 /* Block */: + case 196 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 247 /* CatchClause */: + case 248 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 223 /* CaseBlock */: + case 224 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -52554,7 +53992,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 164 /* ObjectBindingPattern */: + case 165 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -52570,7 +54008,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 165 /* ArrayBindingPattern */: + case 166 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -52585,12 +54023,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 200 /* DoStatement */ || - node.parent.kind === 171 /* CallExpression */ || - node.parent.kind === 172 /* NewExpression */) { + if (node.parent.kind === 201 /* DoStatement */ || + node.parent.kind === 172 /* CallExpression */ || + node.parent.kind === 173 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 175 /* ParenthesizedExpression */) { + if (node.parent.kind === 176 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -52599,21 +54037,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 145 /* Constructor */: - case 201 /* WhileStatement */: - case 200 /* DoStatement */: - case 202 /* ForStatement */: - case 204 /* ForOfStatement */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 175 /* ParenthesizedExpression */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 146 /* Constructor */: + case 202 /* WhileStatement */: + case 201 /* DoStatement */: + case 203 /* ForStatement */: + case 205 /* ForOfStatement */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 176 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -52623,20 +54061,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 248 /* PropertyAssignment */ || - node.parent.kind === 139 /* Parameter */) { + node.parent.kind === 249 /* PropertyAssignment */ || + node.parent.kind === 140 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 174 /* TypeAssertionExpression */) { + if (node.parent.kind === 175 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 200 /* DoStatement */) { + if (node.parent.kind === 201 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -52644,7 +54082,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 204 /* ForOfStatement */) { + if (node.parent.kind === 205 /* ForOfStatement */) { // set using next token return spanInNextNode(node); } @@ -52773,6 +54211,14 @@ var ts; var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0 /* Unknown */; + } + }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { return this.shimHost.getScriptVersion(fileName); }; @@ -53239,7 +54685,8 @@ var ts; errors: [realizeDiagnostic(result.error, "\r\n")] }; } - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); return { options: configFile.options, files: configFile.fileNames, @@ -53334,5 +54781,5 @@ var TypeScript; // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "1.8"; +var toolsVersion = "1.9"; /* tslint:enable:no-unused-variable */ diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 3cd6e23dc1d..2824742c63b 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -160,169 +160,170 @@ declare namespace ts { IsKeyword = 124, ModuleKeyword = 125, NamespaceKeyword = 126, - RequireKeyword = 127, - NumberKeyword = 128, - SetKeyword = 129, - StringKeyword = 130, - SymbolKeyword = 131, - TypeKeyword = 132, - FromKeyword = 133, - GlobalKeyword = 134, - OfKeyword = 135, - QualifiedName = 136, - ComputedPropertyName = 137, - TypeParameter = 138, - Parameter = 139, - Decorator = 140, - PropertySignature = 141, - PropertyDeclaration = 142, - MethodSignature = 143, - MethodDeclaration = 144, - Constructor = 145, - GetAccessor = 146, - SetAccessor = 147, - CallSignature = 148, - ConstructSignature = 149, - IndexSignature = 150, - TypePredicate = 151, - TypeReference = 152, - FunctionType = 153, - ConstructorType = 154, - TypeQuery = 155, - TypeLiteral = 156, - ArrayType = 157, - TupleType = 158, - UnionType = 159, - IntersectionType = 160, - ParenthesizedType = 161, - ThisType = 162, - StringLiteralType = 163, - ObjectBindingPattern = 164, - ArrayBindingPattern = 165, - BindingElement = 166, - ArrayLiteralExpression = 167, - ObjectLiteralExpression = 168, - PropertyAccessExpression = 169, - ElementAccessExpression = 170, - CallExpression = 171, - NewExpression = 172, - TaggedTemplateExpression = 173, - TypeAssertionExpression = 174, - ParenthesizedExpression = 175, - FunctionExpression = 176, - ArrowFunction = 177, - DeleteExpression = 178, - TypeOfExpression = 179, - VoidExpression = 180, - AwaitExpression = 181, - PrefixUnaryExpression = 182, - PostfixUnaryExpression = 183, - BinaryExpression = 184, - ConditionalExpression = 185, - TemplateExpression = 186, - YieldExpression = 187, - SpreadElementExpression = 188, - ClassExpression = 189, - OmittedExpression = 190, - ExpressionWithTypeArguments = 191, - AsExpression = 192, - TemplateSpan = 193, - SemicolonClassElement = 194, - Block = 195, - VariableStatement = 196, - EmptyStatement = 197, - ExpressionStatement = 198, - IfStatement = 199, - DoStatement = 200, - WhileStatement = 201, - ForStatement = 202, - ForInStatement = 203, - ForOfStatement = 204, - ContinueStatement = 205, - BreakStatement = 206, - ReturnStatement = 207, - WithStatement = 208, - SwitchStatement = 209, - LabeledStatement = 210, - ThrowStatement = 211, - TryStatement = 212, - DebuggerStatement = 213, - VariableDeclaration = 214, - VariableDeclarationList = 215, - FunctionDeclaration = 216, - ClassDeclaration = 217, - InterfaceDeclaration = 218, - TypeAliasDeclaration = 219, - EnumDeclaration = 220, - ModuleDeclaration = 221, - ModuleBlock = 222, - CaseBlock = 223, - ImportEqualsDeclaration = 224, - ImportDeclaration = 225, - ImportClause = 226, - NamespaceImport = 227, - NamedImports = 228, - ImportSpecifier = 229, - ExportAssignment = 230, - ExportDeclaration = 231, - NamedExports = 232, - ExportSpecifier = 233, - MissingDeclaration = 234, - ExternalModuleReference = 235, - JsxElement = 236, - JsxSelfClosingElement = 237, - JsxOpeningElement = 238, - JsxText = 239, - JsxClosingElement = 240, - JsxAttribute = 241, - JsxSpreadAttribute = 242, - JsxExpression = 243, - CaseClause = 244, - DefaultClause = 245, - HeritageClause = 246, - CatchClause = 247, - PropertyAssignment = 248, - ShorthandPropertyAssignment = 249, - EnumMember = 250, - SourceFile = 251, - JSDocTypeExpression = 252, - JSDocAllType = 253, - JSDocUnknownType = 254, - JSDocArrayType = 255, - JSDocUnionType = 256, - JSDocTupleType = 257, - JSDocNullableType = 258, - JSDocNonNullableType = 259, - JSDocRecordType = 260, - JSDocRecordMember = 261, - JSDocTypeReference = 262, - JSDocOptionalType = 263, - JSDocFunctionType = 264, - JSDocVariadicType = 265, - JSDocConstructorType = 266, - JSDocThisType = 267, - JSDocComment = 268, - JSDocTag = 269, - JSDocParameterTag = 270, - JSDocReturnTag = 271, - JSDocTypeTag = 272, - JSDocTemplateTag = 273, - SyntaxList = 274, - Count = 275, + ReadonlyKeyword = 127, + RequireKeyword = 128, + NumberKeyword = 129, + SetKeyword = 130, + StringKeyword = 131, + SymbolKeyword = 132, + TypeKeyword = 133, + FromKeyword = 134, + GlobalKeyword = 135, + OfKeyword = 136, + QualifiedName = 137, + ComputedPropertyName = 138, + TypeParameter = 139, + Parameter = 140, + Decorator = 141, + PropertySignature = 142, + PropertyDeclaration = 143, + MethodSignature = 144, + MethodDeclaration = 145, + Constructor = 146, + GetAccessor = 147, + SetAccessor = 148, + CallSignature = 149, + ConstructSignature = 150, + IndexSignature = 151, + TypePredicate = 152, + TypeReference = 153, + FunctionType = 154, + ConstructorType = 155, + TypeQuery = 156, + TypeLiteral = 157, + ArrayType = 158, + TupleType = 159, + UnionType = 160, + IntersectionType = 161, + ParenthesizedType = 162, + ThisType = 163, + StringLiteralType = 164, + ObjectBindingPattern = 165, + ArrayBindingPattern = 166, + BindingElement = 167, + ArrayLiteralExpression = 168, + ObjectLiteralExpression = 169, + PropertyAccessExpression = 170, + ElementAccessExpression = 171, + CallExpression = 172, + NewExpression = 173, + TaggedTemplateExpression = 174, + TypeAssertionExpression = 175, + ParenthesizedExpression = 176, + FunctionExpression = 177, + ArrowFunction = 178, + DeleteExpression = 179, + TypeOfExpression = 180, + VoidExpression = 181, + AwaitExpression = 182, + PrefixUnaryExpression = 183, + PostfixUnaryExpression = 184, + BinaryExpression = 185, + ConditionalExpression = 186, + TemplateExpression = 187, + YieldExpression = 188, + SpreadElementExpression = 189, + ClassExpression = 190, + OmittedExpression = 191, + ExpressionWithTypeArguments = 192, + AsExpression = 193, + TemplateSpan = 194, + SemicolonClassElement = 195, + Block = 196, + VariableStatement = 197, + EmptyStatement = 198, + ExpressionStatement = 199, + IfStatement = 200, + DoStatement = 201, + WhileStatement = 202, + ForStatement = 203, + ForInStatement = 204, + ForOfStatement = 205, + ContinueStatement = 206, + BreakStatement = 207, + ReturnStatement = 208, + WithStatement = 209, + SwitchStatement = 210, + LabeledStatement = 211, + ThrowStatement = 212, + TryStatement = 213, + DebuggerStatement = 214, + VariableDeclaration = 215, + VariableDeclarationList = 216, + FunctionDeclaration = 217, + ClassDeclaration = 218, + InterfaceDeclaration = 219, + TypeAliasDeclaration = 220, + EnumDeclaration = 221, + ModuleDeclaration = 222, + ModuleBlock = 223, + CaseBlock = 224, + ImportEqualsDeclaration = 225, + ImportDeclaration = 226, + ImportClause = 227, + NamespaceImport = 228, + NamedImports = 229, + ImportSpecifier = 230, + ExportAssignment = 231, + ExportDeclaration = 232, + NamedExports = 233, + ExportSpecifier = 234, + MissingDeclaration = 235, + ExternalModuleReference = 236, + JsxElement = 237, + JsxSelfClosingElement = 238, + JsxOpeningElement = 239, + JsxText = 240, + JsxClosingElement = 241, + JsxAttribute = 242, + JsxSpreadAttribute = 243, + JsxExpression = 244, + CaseClause = 245, + DefaultClause = 246, + HeritageClause = 247, + CatchClause = 248, + PropertyAssignment = 249, + ShorthandPropertyAssignment = 250, + EnumMember = 251, + SourceFile = 252, + JSDocTypeExpression = 253, + JSDocAllType = 254, + JSDocUnknownType = 255, + JSDocArrayType = 256, + JSDocUnionType = 257, + JSDocTupleType = 258, + JSDocNullableType = 259, + JSDocNonNullableType = 260, + JSDocRecordType = 261, + JSDocRecordMember = 262, + JSDocTypeReference = 263, + JSDocOptionalType = 264, + JSDocFunctionType = 265, + JSDocVariadicType = 266, + JSDocConstructorType = 267, + JSDocThisType = 268, + JSDocComment = 269, + JSDocTag = 270, + JSDocParameterTag = 271, + JSDocReturnTag = 272, + JSDocTypeTag = 273, + JSDocTemplateTag = 274, + SyntaxList = 275, + Count = 276, FirstAssignment = 56, LastAssignment = 68, FirstReservedWord = 70, LastReservedWord = 105, FirstKeyword = 70, - LastKeyword = 135, + LastKeyword = 136, FirstFutureReservedWord = 106, LastFutureReservedWord = 114, - FirstTypeNode = 151, - LastTypeNode = 163, + FirstTypeNode = 152, + LastTypeNode = 164, FirstPunctuation = 15, LastPunctuation = 68, FirstToken = 0, - LastToken = 135, + LastToken = 136, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -331,40 +332,47 @@ declare namespace ts { LastTemplateToken = 14, FirstBinaryOperator = 25, LastBinaryOperator = 68, - FirstNode = 136, + FirstNode = 137, } enum NodeFlags { None = 0, - Export = 2, - Ambient = 4, - Public = 8, - Private = 16, - Protected = 32, - Static = 64, + Export = 1, + Ambient = 2, + Public = 4, + Private = 8, + Protected = 16, + Static = 32, + Readonly = 64, Abstract = 128, Async = 256, Default = 512, - MultiLine = 1024, - Synthetic = 2048, - DeclarationFile = 4096, - Let = 8192, - Const = 16384, - OctalLiteral = 32768, - Namespace = 65536, - ExportContext = 131072, - ContainsThis = 262144, - HasImplicitReturn = 524288, - HasExplicitReturn = 1048576, - GlobalAugmentation = 2097152, - HasClassExtends = 4194304, - HasDecorators = 8388608, - HasParamDecorators = 16777216, - HasAsyncFunctions = 33554432, - Modifier = 1022, - AccessibilityModifier = 56, - BlockScoped = 24576, - ReachabilityCheckFlags = 1572864, - EmitHelperFlags = 62914560, + Let = 1024, + Const = 2048, + Namespace = 4096, + ExportContext = 8192, + ContainsThis = 16384, + HasImplicitReturn = 32768, + HasExplicitReturn = 65536, + GlobalAugmentation = 131072, + HasClassExtends = 262144, + HasDecorators = 524288, + HasParamDecorators = 1048576, + HasAsyncFunctions = 2097152, + DisallowInContext = 4194304, + YieldContext = 8388608, + DecoratorContext = 16777216, + AwaitContext = 33554432, + ThisNodeHasError = 67108864, + JavaScriptFile = 134217728, + ThisNodeOrAnySubNodesHasError = 268435456, + HasAggregatedChildData = 536870912, + Modifier = 959, + AccessibilityModifier = 28, + BlockScoped = 3072, + ReachabilityCheckFlags = 98304, + EmitHelperFlags = 3932160, + ContextFlags = 62914560, + TypeExcludesFlags = 41943040, } enum JsxFlags { None = 0, @@ -372,10 +380,6 @@ declare namespace ts { IntrinsicNamedElement = 1, /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ IntrinsicIndexedElement = 2, - /** An element backed by a class, class-like, or function value */ - ValueElement = 4, - /** Element resolution failed */ - UnknownElement = 16, IntrinsicElement = 3, } interface Node extends TextRange { @@ -702,7 +706,7 @@ declare namespace ts { expression: LeftHandSideExpression; argumentExpression?: Expression; } - interface CallExpression extends LeftHandSideExpression { + interface CallExpression extends LeftHandSideExpression, Declaration { expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; @@ -1000,6 +1004,7 @@ declare namespace ts { interface JSDocThisType extends JSDocType { type: JSDocType; } + type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDocRecordMember extends PropertySignature { name: Identifier | LiteralExpression; type?: JSDocType; @@ -1040,6 +1045,7 @@ declare namespace ts { moduleName: string; referencedFiles: FileReference[]; languageVariant: LanguageVariant; + isDeclarationFile: boolean; /** * lib.d.ts should have a reference comment like * @@ -1133,6 +1139,7 @@ declare namespace ts { } interface EmitResult { emitSkipped: boolean; + /** Contains declaration emit diagnostics */ diagnostics: Diagnostic[]; } interface TypeChecker { @@ -1177,7 +1184,8 @@ declare namespace ts { buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void; + buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1217,17 +1225,18 @@ declare namespace ts { This = 0, Identifier = 1, } - interface TypePredicate { + interface TypePredicateBase { kind: TypePredicateKind; type: Type; } - interface ThisTypePredicate extends TypePredicate { + interface ThisTypePredicate extends TypePredicateBase { _thisTypePredicateBrand: any; } - interface IdentifierTypePredicate extends TypePredicate { + interface IdentifierTypePredicate extends TypePredicateBase { parameterName: string; parameterIndex: number; } + type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -1328,7 +1337,6 @@ declare namespace ts { ESSymbol = 16777216, ThisType = 33554432, ObjectLiteralPatternWithComputedProperties = 67108864, - PredicateType = 134217728, StringLike = 258, NumberLike = 132, ObjectType = 80896, @@ -1341,9 +1349,6 @@ declare namespace ts { symbol?: Symbol; pattern?: DestructuringPattern; } - interface PredicateType extends Type { - predicate: ThisTypePredicate | IdentifierTypePredicate; - } interface StringLiteralType extends Type { text: string; } @@ -1359,8 +1364,8 @@ declare namespace ts { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; - declaredStringIndexType: Type; - declaredNumberIndexType: Type; + declaredStringIndexInfo: IndexInfo; + declaredNumberIndexInfo: IndexInfo; } interface TypeReference extends ObjectType { target: GenericType; @@ -1394,6 +1399,11 @@ declare namespace ts { String = 0, Number = 1, } + interface IndexInfo { + type: Type; + isReadonly: boolean; + declaration?: SignatureDeclaration; + } interface DiagnosticMessage { key: string; category: DiagnosticCategory; @@ -1429,6 +1439,9 @@ declare namespace ts { Classic = 1, NodeJs = 2, } + type RootPaths = string[]; + type PathSubstitutions = Map; + type TsConfigOnlyOptions = RootPaths | PathSubstitutions; interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -1476,9 +1489,14 @@ declare namespace ts { noImplicitReturns?: boolean; noFallthroughCasesInSwitch?: boolean; forceConsistentCasingInFileNames?: boolean; + baseUrl?: string; + paths?: PathSubstitutions; + rootDirs?: RootPaths; + traceModuleResolution?: boolean; allowSyntheticDefaultImports?: boolean; allowJs?: boolean; - [option: string]: string | number | boolean; + noImplicitUseStrict?: boolean; + [option: string]: string | number | boolean | TsConfigOnlyOptions; } enum ModuleKind { None = 0, @@ -1502,6 +1520,13 @@ declare namespace ts { line: number; character: number; } + enum ScriptKind { + Unknown = 0, + JS = 1, + JSX = 2, + TS = 3, + TSX = 4, + } enum ScriptTarget { ES3 = 0, ES5 = 1, @@ -1521,6 +1546,7 @@ declare namespace ts { interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string; + trace?(s: string): void; directoryExists?(directoryName: string): boolean; } interface ResolvedModule { @@ -1604,6 +1630,7 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; reScanJsxToken(): SyntaxKind; scanJsxToken(): SyntaxKind; + scanJSDocToken(): SyntaxKind; scan(): SyntaxKind; setText(text: string, start?: number, length?: number): void; setOnError(onError: ErrorCallback): void; @@ -1611,6 +1638,7 @@ declare namespace ts { setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; lookAhead(callback: () => T): T; + scanRange(start: number, length: number, callback: () => T): T; tryScan(callback: () => T): T; } function tokenToString(t: SyntaxKind): string; @@ -1661,7 +1689,7 @@ declare namespace ts { declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; + function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { @@ -1702,8 +1730,8 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions): ParsedCommandLine; - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string): ParsedCommandLine; + function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; @@ -1796,6 +1824,7 @@ declare namespace ts { getNewLine?(): string; getProjectVersion?(): string; getScriptFileNames(): string[]; + getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; getLocalizedDiagnosticMessages?(): any; @@ -2164,7 +2193,7 @@ declare namespace ts { * @parm version Current version of the file. Only used if the file was not found * in the registry and a new one was created. */ - acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; + acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; /** * Request an updated version of an already existing SourceFile with a given fileName * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile @@ -2177,7 +2206,7 @@ declare namespace ts { * @param scriptSnapshot Text of the file. * @param version Current version of the file. */ - updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile; + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; /** * Informs the DocumentRegistry that a file is not needed any longer. * @@ -2301,7 +2330,7 @@ declare namespace ts { } 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; + function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index bbe9a4b07e3..8dafad54257 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -13,6 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +var __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 ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword @@ -156,190 +161,191 @@ var ts; SyntaxKind[SyntaxKind["IsKeyword"] = 124] = "IsKeyword"; SyntaxKind[SyntaxKind["ModuleKeyword"] = 125] = "ModuleKeyword"; SyntaxKind[SyntaxKind["NamespaceKeyword"] = 126] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 127] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 128] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 129] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 130] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 131] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 132] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 133] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 134] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 135] = "OfKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 127] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 128] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 129] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 130] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 131] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 132] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 133] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 134] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 135] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 136] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 136] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 137] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 137] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 138] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 138] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 139] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 140] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 139] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 140] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 141] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 142] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 143] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 144] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 145] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 146] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 147] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 148] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 149] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 150] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 142] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 143] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 144] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 145] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 146] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 147] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 148] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 149] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 150] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 151] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 151] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 152] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 153] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 154] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 155] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 156] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 157] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 158] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 159] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 160] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 161] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 162] = "ThisType"; - SyntaxKind[SyntaxKind["StringLiteralType"] = 163] = "StringLiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 152] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 153] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 154] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 155] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 156] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 157] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 158] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 159] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 160] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 161] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 162] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 163] = "ThisType"; + SyntaxKind[SyntaxKind["StringLiteralType"] = 164] = "StringLiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 164] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 165] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 166] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 165] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 166] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 167] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 167] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 168] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 169] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 170] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 171] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 172] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 173] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 174] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 175] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 176] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 177] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 178] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 179] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 180] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 181] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 182] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 183] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 184] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 185] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 186] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 187] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 188] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 189] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 190] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 191] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 192] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 168] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 169] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 170] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 171] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 172] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 173] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 174] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 175] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 176] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 177] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 178] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 179] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 180] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 181] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 182] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 183] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 184] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 185] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 187] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 188] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 189] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 190] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 191] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 192] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 193] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 193] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 194] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 194] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 195] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 195] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 196] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 197] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 198] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 199] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 200] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 201] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 202] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 203] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 204] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 205] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 206] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 207] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 208] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 209] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 210] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 211] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 212] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 213] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 214] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 215] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 216] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 217] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 218] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 219] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 220] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 221] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 222] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 223] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 224] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 225] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 226] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 227] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 228] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 229] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 230] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 231] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 232] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 233] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 234] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 196] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 197] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 198] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 199] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 200] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 201] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 202] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 203] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 204] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 205] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 206] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 207] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 208] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 209] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 210] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 211] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 212] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 213] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 214] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 215] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 216] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 217] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 218] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 219] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 220] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 221] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 222] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 223] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 224] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 225] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 226] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 227] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 228] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 229] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 230] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 231] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 232] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 233] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 234] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 235] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 235] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 236] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 236] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 237] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 238] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 239] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 240] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 241] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 242] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 243] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 237] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 238] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 239] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 240] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 241] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 242] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 243] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 244] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 244] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 245] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 246] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 247] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 245] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 246] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 247] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 248] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 248] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 249] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 249] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 250] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 250] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 251] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 251] = "SourceFile"; - // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 252] = "JSDocTypeExpression"; - // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 253] = "JSDocAllType"; - // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 254] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 255] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 256] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 257] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 258] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 259] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 260] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 261] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 262] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 263] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 264] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 265] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 266] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 267] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 268] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 269] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 270] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 271] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 272] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 273] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["SourceFile"] = 252] = "SourceFile"; + // JSDoc nodes + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 253] = "JSDocTypeExpression"; + // The * type + SyntaxKind[SyntaxKind["JSDocAllType"] = 254] = "JSDocAllType"; + // The ? type + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 255] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 256] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 257] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 258] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 259] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 260] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 261] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 262] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 263] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 264] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 265] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 266] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 267] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 268] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 269] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 270] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 271] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 272] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 273] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 274] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 274] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 275] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 275] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 276] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 135] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 136] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 151] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 163] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 152] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 164] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 135] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 136] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -348,83 +354,58 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 136] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 137] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Export"] = 2] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 4] = "Ambient"; - NodeFlags[NodeFlags["Public"] = 8] = "Public"; - NodeFlags[NodeFlags["Private"] = 16] = "Private"; - NodeFlags[NodeFlags["Protected"] = 32] = "Protected"; - NodeFlags[NodeFlags["Static"] = 64] = "Static"; + NodeFlags[NodeFlags["Export"] = 1] = "Export"; + NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; + NodeFlags[NodeFlags["Public"] = 4] = "Public"; + NodeFlags[NodeFlags["Private"] = 8] = "Private"; + NodeFlags[NodeFlags["Protected"] = 16] = "Protected"; + NodeFlags[NodeFlags["Static"] = 32] = "Static"; + NodeFlags[NodeFlags["Readonly"] = 64] = "Readonly"; NodeFlags[NodeFlags["Abstract"] = 128] = "Abstract"; NodeFlags[NodeFlags["Async"] = 256] = "Async"; NodeFlags[NodeFlags["Default"] = 512] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 1024] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 2048] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 4096] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 8192] = "Let"; - NodeFlags[NodeFlags["Const"] = 16384] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 32768] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 65536] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 131072] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 262144] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 524288] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 1048576] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 2097152] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasClassExtends"] = 4194304] = "HasClassExtends"; - NodeFlags[NodeFlags["HasDecorators"] = 8388608] = "HasDecorators"; - NodeFlags[NodeFlags["HasParamDecorators"] = 16777216] = "HasParamDecorators"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 33554432] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 1572864] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 62914560] = "EmitHelperFlags"; + NodeFlags[NodeFlags["Let"] = 1024] = "Let"; + NodeFlags[NodeFlags["Const"] = 2048] = "Const"; + NodeFlags[NodeFlags["Namespace"] = 4096] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 8192] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 16384] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 32768] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 65536] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 131072] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 262144] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 524288] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 1048576] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2097152] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4194304] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8388608] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16777216] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 33554432] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 67108864] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 134217728] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 268435456] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 536870912] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["Modifier"] = 959] = "Modifier"; + NodeFlags[NodeFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + NodeFlags[NodeFlags["BlockScoped"] = 3072] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 98304] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 3932160] = "EmitHelperFlags"; + // Parsing context flags + NodeFlags[NodeFlags["ContextFlags"] = 62914560] = "ContextFlags"; + // Exclude these flags when parsing a Type + NodeFlags[NodeFlags["TypeExcludesFlags"] = 41943040] = "TypeExcludesFlags"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; - /* @internal */ - (function (ParserContextFlags) { - ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; - // If this node was parsed in a context where 'in-expressions' are not allowed. - ParserContextFlags[ParserContextFlags["DisallowIn"] = 1] = "DisallowIn"; - // If this node was parsed in the 'yield' context created when parsing a generator. - ParserContextFlags[ParserContextFlags["Yield"] = 2] = "Yield"; - // If this node was parsed as part of a decorator - ParserContextFlags[ParserContextFlags["Decorator"] = 4] = "Decorator"; - // If this node was parsed in the 'await' context created when parsing an async function. - ParserContextFlags[ParserContextFlags["Await"] = 8] = "Await"; - // If the parser encountered an error when parsing the code that created this node. Note - // the parser only sets this directly on the node it creates right after encountering the - // error. - ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; - // This node was parsed in a JavaScript file and can be processed differently. For example - // its type can be specified usign a JSDoc comment. - ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 32] = "JavaScriptFile"; - // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; - // Exclude these flags when parsing a Type - ParserContextFlags[ParserContextFlags["TypeExcludesFlags"] = 10] = "TypeExcludesFlags"; - // Context flags computed by aggregating child flags upwards. - // Used during incremental parsing to determine if this node or any of its children had an - // error. Computed only once and then cached. - ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; - // Used to know if we've computed data from children and cached it in this node. - ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; - })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); - var ParserContextFlags = ts.ParserContextFlags; (function (JsxFlags) { JsxFlags[JsxFlags["None"] = 0] = "None"; /** An element from a named property of the JSX.IntrinsicElements interface */ JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; - /** An element backed by a class, class-like, or function value */ - JsxFlags[JsxFlags["ValueElement"] = 4] = "ValueElement"; - /** Element resolution failed */ - JsxFlags[JsxFlags["UnknownElement"] = 16] = "UnknownElement"; JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; })(ts.JsxFlags || (ts.JsxFlags = {})); var JsxFlags = ts.JsxFlags; @@ -594,13 +575,17 @@ var ts; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalArguments"] = 2048] = "LexicalArguments"; - NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 4096] = "CaptureArguments"; - // Values for enum members have been computed, and any errors have been reported for them. - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 8192] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 16384] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; - NodeCheckFlags[NodeCheckFlags["LoopWithBlockScopedBindingCapturedInFunction"] = 65536] = "LoopWithBlockScopedBindingCapturedInFunction"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); var NodeCheckFlags = ts.NodeCheckFlags; (function (TypeFlags) { @@ -636,7 +621,6 @@ var ts; TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; TypeFlags[TypeFlags["ThisType"] = 33554432] = "ThisType"; TypeFlags[TypeFlags["ObjectLiteralPatternWithComputedProperties"] = 67108864] = "ObjectLiteralPatternWithComputedProperties"; - TypeFlags[TypeFlags["PredicateType"] = 134217728] = "PredicateType"; /* @internal */ TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; /* @internal */ @@ -647,7 +631,7 @@ var ts; TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 140509184] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; })(ts.TypeFlags || (ts.TypeFlags = {})); @@ -707,6 +691,14 @@ var ts; NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; })(ts.NewLineKind || (ts.NewLineKind = {})); var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; @@ -1278,6 +1270,15 @@ var ts; }; } ts.createFileDiagnostic = createFileDiagnostic; + /* internal */ + function formatMessage(dummy, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); + } + return text; + } + ts.formatMessage = formatMessage; function createCompilerDiagnostic(message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 1) { @@ -1480,7 +1481,7 @@ var ts; } ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; function getNormalizedPathComponentsOfUrl(url) { - // Get root length of http://www.website.com/folder1/foler2/ + // Get root length of http://www.website.com/folder1/folder2/ // In this example the root is: http://www.website.com/ // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] var urlLength = url.length; @@ -1505,7 +1506,7 @@ var ts; var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); if (indexOfNextSlash !== -1) { // Found the "/" after the website.com so the root is length of http://www.website.com/ - // and get components afetr the root normally like any other folder components + // and get components after the root normally like any other folder components rootLength = indexOfNextSlash + 1; return normalizedPathComponents(url, rootLength); } @@ -1962,15 +1963,13 @@ var ts; } } } - /** - * @param watcherPath is the path from which the watcher is triggered. - */ function fileEventHandler(eventName, relativeFileName, baseDirPath) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" var filePath = typeof relativeFileName !== "string" ? undefined : ts.toPath(relativeFileName, baseDirPath, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)); - if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) { + // Some applications save a working file via rename operations + if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks.contains(filePath)) { for (var _i = 0, _a = fileWatcherCallbacks.get(filePath); _i < _a.length; _i++) { var fileCallback = _a[_i]; fileCallback(filePath); @@ -2000,7 +1999,7 @@ var ts; // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { + if (!fileExists(fileName)) { return undefined; } var buffer = _fs.readFileSync(fileName); @@ -2046,6 +2045,29 @@ var ts; function getCanonicalPath(path) { return useCaseSensitiveFileNames ? path : path.toLowerCase(); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); + function fileSystemEntryExists(path, entryKind) { + try { + var stat = _fs.statSync(path); + switch (entryKind) { + case 0 /* File */: return stat.isFile(); + case 1 /* Directory */: return stat.isDirectory(); + } + } + catch (e) { + return false; + } + } + function fileExists(path) { + return fileSystemEntryExists(path, 0 /* File */); + } + function directoryExists(path) { + return fileSystemEntryExists(path, 1 /* Directory */); + } function readDirectory(path, extension, exclude) { var result = []; exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); }); @@ -2085,7 +2107,7 @@ var ts; readFile: readFile, writeFile: writeFile, watchFile: function (filePath, callback) { - // Node 4.0 stablized the `fs.watch` function on Windows which avoids polling + // Node 4.0 stabilized the `fs.watch` function on Windows which avoids polling // and is more efficient than `fs.watchFile` (ref: https://github.com/nodejs/node/pull/2649 // and https://github.com/Microsoft/TypeScript/issues/4643), therefore // if the current node.js version is newer than 4, use `fs.watch` instead. @@ -2119,12 +2141,8 @@ var ts; resolvePath: function (path) { return _path.resolve(path); }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, + fileExists: fileExists, + directoryExists: directoryExists, createDirectory: function (directoryName) { if (!this.directoryExists(directoryName)) { _fs.mkdirSync(directoryName); @@ -2214,6 +2232,7 @@ var ts; An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An_index_signature_must_have_a_type_annotation_1021", message: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_must_have_a_type_annotation_1022", message: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An_index_signature_parameter_type_must_be_string_or_number_1023", message: "An index signature parameter type must be 'string' or 'number'." }, + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: { code: 1024, category: ts.DiagnosticCategory.Error, key: "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", message: "'readonly' modifier can only appear on a property declaration or index signature." }, Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility_modifier_already_seen_1028", message: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "_0_modifier_must_precede_1_modifier_1029", message: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "_0_modifier_already_seen_1030", message: "'{0}' modifier already seen." }, @@ -2227,7 +2246,7 @@ var ts; _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_a_class_declaration_1041", message: "'{0}' modifier cannot be used with a class declaration." }, _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_here_1042", message: "'{0}' modifier cannot be used here." }, _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_data_property_1043", message: "'{0}' modifier cannot appear on a data property." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_element_1044", message: "'{0}' modifier cannot appear on a module element." }, + _0_modifier_cannot_appear_on_a_module_or_namespace_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", message: "'{0}' modifier cannot appear on a module or namespace element." }, A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", message: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046", message: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_cannot_be_optional_1047", message: "A rest parameter cannot be optional." }, @@ -2246,8 +2265,11 @@ var ts; Enum_member_must_have_initializer: { code: 1061, category: ts.DiagnosticCategory.Error, key: "Enum_member_must_have_initializer_1061", message: "Enum member must have initializer." }, _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_cannot_be_used_in_a_namespace_1063", message: "An export assignment cannot be used in a namespace." }, + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { code: 1064, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", message: "The return type of an async function or method must be the global Promise type." }, In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { code: 1066, category: ts.DiagnosticCategory.Error, key: "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", message: "In ambient enum declarations member initializer must be constant expression." }, Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: ts.DiagnosticCategory.Error, key: "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", message: "Unexpected token. A constructor, method, accessor, or property was expected." }, + _0_modifier_cannot_appear_on_a_type_member: { code: 1070, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_a_type_member_1070", message: "'{0}' modifier cannot appear on a type member." }, + _0_modifier_cannot_appear_on_an_index_signature: { code: 1071, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_appear_on_an_index_signature_1071", message: "'{0}' modifier cannot appear on an index signature." }, A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", message: "A '{0}' modifier cannot be used with an import declaration." }, Invalid_reference_directive_syntax: { code: 1084, category: ts.DiagnosticCategory.Error, key: "Invalid_reference_directive_syntax_1084", message: "Invalid 'reference' directive syntax." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_1085", message: "Octal literals are not available when targeting ECMAScript 5 and higher." }, @@ -2303,10 +2325,9 @@ var ts; String_literal_expected: { code: 1141, category: ts.DiagnosticCategory.Error, key: "String_literal_expected_1141", message: "String literal expected." }, Line_break_not_permitted_here: { code: 1142, category: ts.DiagnosticCategory.Error, key: "Line_break_not_permitted_here_1142", message: "Line break not permitted here." }, or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: ts.DiagnosticCategory.Error, key: "Modifiers_not_permitted_on_index_signature_members_1145", message: "Modifiers not permitted on index signature members." }, Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." }, Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." }, - Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_optio_1148", message: "Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file." }, + Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting__1148", message: "Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" }, @@ -2366,7 +2387,7 @@ var ts; Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", message: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", message: "Invalid use of '{0}'. Modules are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: ts.DiagnosticCategory.Error, key: "Export_assignment_is_not_supported_when_module_flag_is_system_1218", message: "Export assignment is not supported when '--module' flag is 'system'." }, - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Speci_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { code: 1219, category: ts.DiagnosticCategory.Error, key: "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", message: "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning." }, Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: ts.DiagnosticCategory.Error, key: "Generators_are_only_available_when_targeting_ECMAScript_6_or_higher_1220", message: "Generators are only available when targeting ECMAScript 6 or higher." }, Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: ts.DiagnosticCategory.Error, key: "Generators_are_not_allowed_in_an_ambient_context_1221", message: "Generators are not allowed in an ambient context." }, An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: ts.DiagnosticCategory.Error, key: "An_overload_signature_cannot_be_declared_as_a_generator_1222", message: "An overload signature cannot be declared as a generator." }, @@ -2375,6 +2396,7 @@ var ts; Cannot_find_parameter_0: { code: 1225, category: ts.DiagnosticCategory.Error, key: "Cannot_find_parameter_0_1225", message: "Cannot find parameter '{0}'." }, Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: ts.DiagnosticCategory.Error, key: "Type_predicate_0_is_not_assignable_to_1_1226", message: "Type predicate '{0}' is not assignable to '{1}'." }, Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: ts.DiagnosticCategory.Error, key: "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", message: "Parameter '{0}' is not in the same position as parameter '{1}'." }, + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", message: "A type predicate is only allowed in return type position for functions and methods." }, A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_a_rest_parameter_1229", message: "A type predicate cannot reference a rest parameter." }, A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: ts.DiagnosticCategory.Error, key: "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", message: "A type predicate cannot reference element '{0}' in a binding pattern." }, An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: ts.DiagnosticCategory.Error, key: "An_export_assignment_can_only_be_used_in_a_module_1231", message: "An export assignment can only be used in a module." }, @@ -2388,7 +2410,7 @@ var ts; Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", message: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", message: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", message: "Unable to resolve signature of method decorator when called as an expression." }, - abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_or_method_declaration_1242", message: "'abstract' modifier can only appear on a class or method declaration." }, + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", message: "'abstract' modifier can only appear on a class, method, or property declaration." }, _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: ts.DiagnosticCategory.Error, key: "_0_modifier_cannot_be_used_with_1_modifier_1243", message: "'{0}' modifier cannot be used with '{1}' modifier." }, Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: ts.DiagnosticCategory.Error, key: "Abstract_methods_can_only_appear_within_an_abstract_class_1244", message: "Abstract methods can only appear within an abstract class." }, Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: ts.DiagnosticCategory.Error, key: "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", message: "Method '{0}' cannot have an implementation because it is marked abstract." }, @@ -2481,7 +2503,7 @@ var ts; get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: ts.DiagnosticCategory.Error, key: "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", message: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_not_exported_2383", message: "Overload signatures must all be exported or not exported." }, + Overload_signatures_must_all_be_exported_or_non_exported: { code: 2383, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_exported_or_non_exported_2383", message: "Overload signatures must all be exported or non-exported." }, Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", message: "Overload signatures must all be ambient or non-ambient." }, Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_public_private_or_protected_2385", message: "Overload signatures must all be public, private or protected." }, Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_optional_or_required_2386", message: "Overload signatures must all be optional or required." }, @@ -2514,7 +2536,6 @@ var ts; Class_name_cannot_be_0: { code: 2414, category: ts.DiagnosticCategory.Error, key: "Class_name_cannot_be_0_2414", message: "Class name cannot be '{0}'" }, Class_0_incorrectly_extends_base_class_1: { code: 2415, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_extends_base_class_1_2415", message: "Class '{0}' incorrectly extends base class '{1}'." }, Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: ts.DiagnosticCategory.Error, key: "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", message: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: ts.DiagnosticCategory.Error, key: "Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0_2419", message: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, Class_0_incorrectly_implements_interface_1: { code: 2420, category: ts.DiagnosticCategory.Error, key: "Class_0_incorrectly_implements_interface_1_2420", message: "Class '{0}' incorrectly implements interface '{1}'." }, A_class_may_only_implement_another_class_or_interface: { code: 2422, category: ts.DiagnosticCategory.Error, key: "A_class_may_only_implement_another_class_or_interface_2422", message: "A class may only implement another class or interface." }, Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, @@ -2522,7 +2543,7 @@ var ts; Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", message: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", message: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, Interface_name_cannot_be_0: { code: 2427, category: ts.DiagnosticCategory.Error, key: "Interface_name_cannot_be_0_2427", message: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_interface_must_have_identical_type_parameters_2428", message: "All declarations of an interface must have identical type parameters." }, + All_declarations_of_0_must_have_identical_type_parameters: { code: 2428, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_type_parameters_2428", message: "All declarations of '{0}' must have identical type parameters." }, Interface_0_incorrectly_extends_interface_1: { code: 2430, category: ts.DiagnosticCategory.Error, key: "Interface_0_incorrectly_extends_interface_1_2430", message: "Interface '{0}' incorrectly extends interface '{1}'." }, Enum_name_cannot_be_0: { code: 2431, category: ts.DiagnosticCategory.Error, key: "Enum_name_cannot_be_0_2431", message: "Enum name cannot be '{0}'" }, In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: ts.DiagnosticCategory.Error, key: "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", message: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, @@ -2542,8 +2563,8 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_2449", message: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_2450", message: "Left-hand side of assignment expression cannot be a constant." }, + The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, + Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -2576,8 +2597,8 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant_2485", message: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant_2486", message: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, + The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, + The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, @@ -2603,7 +2624,7 @@ var ts; Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509", message: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base_constructors_must_all_have_the_same_return_type_2510", message: "Base constructors must all have the same return type." }, Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot_create_an_instance_of_the_abstract_class_0_2511", message: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_not_abstract_2512", message: "Overload signatures must all be abstract or not abstract." }, + Overload_signatures_must_all_be_abstract_or_non_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", message: "Overload signatures must all be abstract or non-abstract." }, Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", message: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes_containing_abstract_methods_must_be_marked_abstract_2514", message: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", message: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, @@ -2619,6 +2640,8 @@ var ts; A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { code: 2526, category: ts.DiagnosticCategory.Error, key: "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", message: "A 'this' type is available only in a non-static member of a class or interface." }, The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { code: 2527, category: ts.DiagnosticCategory.Error, key: "The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary_2527", message: "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary." }, A_module_cannot_have_multiple_default_exports: { code: 2528, category: ts.DiagnosticCategory.Error, key: "A_module_cannot_have_multiple_default_exports_2528", message: "A module cannot have multiple default exports." }, + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { code: 2529, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions." }, + Property_0_is_incompatible_with_index_signature: { code: 2530, category: ts.DiagnosticCategory.Error, key: "Property_0_is_incompatible_with_index_signature_2530", message: "Property '{0}' is incompatible with index signature." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2648,6 +2671,12 @@ var ts; export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { code: 2669, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", message: "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations." }, Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { code: 2670, category: ts.DiagnosticCategory.Error, key: "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", message: "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context." }, + Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { code: 2671, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671", message: "Cannot augment module '{0}' because it resolves to a non-module entity." }, + Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: { code: 2672, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_a_0_constructor_type_to_a_1_constructor_type_2672", message: "Cannot assign a '{0}' constructor type to a '{1}' constructor type." }, + Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: { code: 2673, category: ts.DiagnosticCategory.Error, key: "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673", message: "Constructor of class '{0}' is private and only accessible within the class declaration." }, + Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: { code: 2674, category: ts.DiagnosticCategory.Error, key: "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674", message: "Constructor of class '{0}' is protected and only accessible within the class declaration." }, + Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: { code: 2675, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_a_class_0_Class_constructor_is_marked_as_private_2675", message: "Cannot extend a class '{0}'. Class constructor is marked as private." }, + Accessors_must_both_be_abstract_or_non_abstract: { code: 2676, category: ts.DiagnosticCategory.Error, key: "Accessors_must_both_be_abstract_or_non_abstract_2676", message: "Accessors must both be abstract or non-abstract." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2736,7 +2765,10 @@ var ts; Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { code: 5056, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056", message: "Cannot write file '{0}' because it would be overwritten by multiple input files." }, Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { code: 5057, category: ts.DiagnosticCategory.Error, key: "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057", message: "Cannot find a tsconfig.json file at the specified directory: '{0}'" }, The_specified_path_does_not_exist_Colon_0: { code: 5058, category: ts.DiagnosticCategory.Error, key: "The_specified_path_does_not_exist_Colon_0_5058", message: "The specified path does not exist: '{0}'" }, - Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier: { code: 5059, category: ts.DiagnosticCategory.Error, key: "Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", message: "Invalide value for '--reactNamespace'. '{0}' is not a valid identifier." }, + Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: { code: 5059, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", message: "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier." }, + Option_paths_cannot_be_used_without_specifying_baseUrl_option: { code: 5060, category: ts.DiagnosticCategory.Error, key: "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", message: "Option 'paths' cannot be used without specifying '--baseUrl' option." }, + Pattern_0_can_have_at_most_one_Asterisk_character: { code: 5061, category: ts.DiagnosticCategory.Error, key: "Pattern_0_can_have_at_most_one_Asterisk_character_5061", message: "Pattern '{0}' can have at most one '*' character" }, + Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { code: 5062, category: ts.DiagnosticCategory.Error, key: "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", message: "Substitution '{0}' in pattern '{1}' in can have at most one '*' character" }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, 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_6003", message: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2770,7 +2802,7 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_map_file_6043", message: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_expects_an_argument_6044", message: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated_quoted_string_in_response_file_0_6045", message: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es2015'." }, + Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none_6046", message: "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'none'." }, Argument_for_target_option_must_be_ES3_ES5_or_ES2015: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument_for_target_option_must_be_ES3_ES5_or_ES2015_6047", message: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", message: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported_locale_0_6049", message: "Unsupported locale '{0}'." }, @@ -2787,6 +2819,7 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, + Option_0_can_only_be_specified_in_tsconfig_json_file: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_specified_in_tsconfig_json_file_6064", message: "Option '{0}' can only be specified in 'tsconfig.json' file." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "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_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -2803,8 +2836,36 @@ var ts; Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "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_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Only_amd_and_system_modules_are_supported_alongside_0: { code: 6082, category: ts.DiagnosticCategory.Error, key: "Only_amd_and_system_modules_are_supported_alongside_0_6082", message: "Only 'amd' and 'system' modules are supported alongside --{0}." }, - Allow_javascript_files_to_be_compiled: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6083", message: "Allow javascript files to be compiled." }, + Base_directory_to_resolve_non_absolute_module_names: { code: 6083, category: ts.DiagnosticCategory.Message, key: "Base_directory_to_resolve_non_absolute_module_names_6083", message: "Base directory to resolve non-absolute module names." }, Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specifies_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specifies the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Enable_tracing_of_the_module_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_module_resolution_process_6085", message: "Enable tracing of the module resolution process." }, + Resolving_module_0_from_1: { code: 6086, category: ts.DiagnosticCategory.Message, key: "Resolving_module_0_from_1_6086", message: "======== Resolving module '{0}' from '{1}'. ========" }, + Explicitly_specified_module_resolution_kind_Colon_0: { code: 6087, category: ts.DiagnosticCategory.Message, key: "Explicitly_specified_module_resolution_kind_Colon_0_6087", message: "Explicitly specified module resolution kind: '{0}'." }, + Module_resolution_kind_is_not_specified_using_0: { code: 6088, category: ts.DiagnosticCategory.Message, key: "Module_resolution_kind_is_not_specified_using_0_6088", message: "Module resolution kind is not specified, using '{0}'." }, + Module_name_0_was_successfully_resolved_to_1: { code: 6089, category: ts.DiagnosticCategory.Message, key: "Module_name_0_was_successfully_resolved_to_1_6089", message: "======== Module name '{0}' was successfully resolved to '{1}'. ========" }, + Module_name_0_was_not_resolved: { code: 6090, category: ts.DiagnosticCategory.Message, key: "Module_name_0_was_not_resolved_6090", message: "======== Module name '{0}' was not resolved. ========" }, + paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: { code: 6091, category: ts.DiagnosticCategory.Message, key: "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091", message: "'paths' option is specified, looking for a pattern to match module name '{0}'." }, + Module_name_0_matched_pattern_1: { code: 6092, category: ts.DiagnosticCategory.Message, key: "Module_name_0_matched_pattern_1_6092", message: "Module name '{0}', matched pattern '{1}'." }, + Trying_substitution_0_candidate_module_location_Colon_1: { code: 6093, category: ts.DiagnosticCategory.Message, key: "Trying_substitution_0_candidate_module_location_Colon_1_6093", message: "Trying substitution '{0}', candidate module location: '{1}'." }, + Resolving_module_name_0_relative_to_base_url_1_2: { code: 6094, category: ts.DiagnosticCategory.Message, key: "Resolving_module_name_0_relative_to_base_url_1_2_6094", message: "Resolving module name '{0}' relative to base url '{1}' - '{2}'." }, + Loading_module_as_file_Slash_folder_candidate_module_location_0: { code: 6095, category: ts.DiagnosticCategory.Message, key: "Loading_module_as_file_Slash_folder_candidate_module_location_0_6095", message: "Loading module as file / folder, candidate module location '{0}'." }, + File_0_does_not_exist: { code: 6096, category: ts.DiagnosticCategory.Message, key: "File_0_does_not_exist_6096", message: "File '{0}' does not exist." }, + File_0_exist_use_it_as_a_module_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_module_resolution_result_6097", message: "File '{0}' exist - use it as a module resolution result." }, + Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, + Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, + package_json_does_not_have_typings_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_typings_field_6100", message: "'package.json' does not have 'typings' field." }, + package_json_has_typings_field_0_that_references_1: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_typings_field_0_that_references_1_6101", message: "'package.json' has 'typings' field '{0}' that references '{1}'." }, + Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, + Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, + Checking_if_0_is_the_longest_matching_prefix_for_1_2: { code: 6104, category: ts.DiagnosticCategory.Message, key: "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104", message: "Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'." }, + Expected_type_of_typings_field_in_package_json_to_be_string_got_0: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_typings_field_in_package_json_to_be_string_got_0_6105", message: "Expected type of 'typings' field in 'package.json' to be 'string', got '{0}'." }, + baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: { code: 6106, category: ts.DiagnosticCategory.Message, key: "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106", message: "'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'" }, + rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: { code: 6107, category: ts.DiagnosticCategory.Message, key: "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107", message: "'rootDirs' option is set, using it to resolve relative module name '{0}'" }, + Longest_matching_prefix_for_0_is_1: { code: 6108, category: ts.DiagnosticCategory.Message, key: "Longest_matching_prefix_for_0_is_1_6108", message: "Longest matching prefix for '{0}' is '{1}'" }, + Loading_0_from_the_root_dir_1_candidate_location_2: { code: 6109, category: ts.DiagnosticCategory.Message, key: "Loading_0_from_the_root_dir_1_candidate_location_2_6109", message: "Loading '{0}' from the root dir '{1}', candidate location '{2}'" }, + Trying_other_entries_in_rootDirs: { code: 6110, category: ts.DiagnosticCategory.Message, key: "Trying_other_entries_in_rootDirs_6110", message: "Trying other entries in 'rootDirs'" }, + Module_resolution_using_rootDirs_has_failed: { code: 6111, category: ts.DiagnosticCategory.Message, key: "Module_resolution_using_rootDirs_has_failed_6111", message: "Module resolution using 'rootDirs' has failed" }, + Do_not_emit_use_strict_directives_in_module_output: { code: 6112, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_use_strict_directives_in_module_output_6112", message: "Do not emit 'use strict' directives in module output." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -2843,7 +2904,6 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "property_declarations_can_only_be_used_in_a_ts_file_8014", message: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "enum_declarations_can_only_be_used_in_a_ts_file_8015", message: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016", message: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "decorators_can_only_be_used_in_a_ts_file_8017", message: "'decorators' can only be used in a .ts file." }, Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", message: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "class_expressions_are_not_currently_supported_9003", message: "'class' expressions are not currently supported." }, JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", message: "JSX attributes must only be assigned a non-empty 'expression'." }, @@ -2854,7 +2914,8 @@ var ts; 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_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17006, category: ts.DiagnosticCategory.Error, key: "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", message: "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, - JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." } + JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." }, + super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." } }; })(ts || (ts = {})); /// @@ -2890,7 +2951,7 @@ var ts; "false": 84 /* FalseKeyword */, "finally": 85 /* FinallyKeyword */, "for": 86 /* ForKeyword */, - "from": 133 /* FromKeyword */, + "from": 134 /* FromKeyword */, "function": 87 /* FunctionKeyword */, "get": 123 /* GetKeyword */, "if": 88 /* IfKeyword */, @@ -2905,25 +2966,26 @@ var ts; "namespace": 126 /* NamespaceKeyword */, "new": 92 /* NewKeyword */, "null": 93 /* NullKeyword */, - "number": 128 /* NumberKeyword */, + "number": 129 /* NumberKeyword */, "package": 109 /* PackageKeyword */, "private": 110 /* PrivateKeyword */, "protected": 111 /* ProtectedKeyword */, "public": 112 /* PublicKeyword */, - "require": 127 /* RequireKeyword */, - "global": 134 /* GlobalKeyword */, + "readonly": 127 /* ReadonlyKeyword */, + "require": 128 /* RequireKeyword */, + "global": 135 /* GlobalKeyword */, "return": 94 /* ReturnKeyword */, - "set": 129 /* SetKeyword */, + "set": 130 /* SetKeyword */, "static": 113 /* StaticKeyword */, - "string": 130 /* StringKeyword */, + "string": 131 /* StringKeyword */, "super": 95 /* SuperKeyword */, "switch": 96 /* SwitchKeyword */, - "symbol": 131 /* SymbolKeyword */, + "symbol": 132 /* SymbolKeyword */, "this": 97 /* ThisKeyword */, "throw": 98 /* ThrowKeyword */, "true": 99 /* TrueKeyword */, "try": 100 /* TryKeyword */, - "type": 132 /* TypeKeyword */, + "type": 133 /* TypeKeyword */, "typeof": 101 /* TypeOfKeyword */, "var": 102 /* VarKeyword */, "void": 103 /* VoidKeyword */, @@ -2932,7 +2994,7 @@ var ts; "yield": 114 /* YieldKeyword */, "async": 118 /* AsyncKeyword */, "await": 119 /* AwaitKeyword */, - "of": 135 /* OfKeyword */, + "of": 136 /* OfKeyword */, "{": 15 /* OpenBraceToken */, "}": 16 /* CloseBraceToken */, "(": 17 /* OpenParenToken */, @@ -3304,7 +3366,7 @@ var ts; } ts.skipTrivia = skipTrivia; // All conflict markers consist of the same character repeated seven times. If it is - // a <<<<<<< or >>>>>>> marker then it is also followd by a space. + // a <<<<<<< or >>>>>>> marker then it is also followed by a space. var mergeConflictMarkerLength = "<<<<<<<".length; function isConflictMarkerTrivia(text, pos) { ts.Debug.assert(pos >= 0); @@ -3336,7 +3398,7 @@ var ts; } else { ts.Debug.assert(ch === 61 /* equals */); - // Consume everything from the start of the mid-conlict marker to the start of the next + // Consume everything from the start of the mid-conflict marker to the start of the next // end-conflict marker. while (pos < len) { var ch_1 = text.charCodeAt(pos); @@ -3519,6 +3581,7 @@ var ts; scanJsxIdentifier: scanJsxIdentifier, reScanJsxToken: reScanJsxToken, scanJsxToken: scanJsxToken, + scanJSDocToken: scanJSDocToken, scan: scan, setText: setText, setScriptTarget: setScriptTarget, @@ -3526,7 +3589,8 @@ var ts; setOnError: setOnError, setTextPos: setTextPos, tryScan: tryScan, - lookAhead: lookAhead + lookAhead: lookAhead, + scanRange: scanRange }; function error(message, length) { if (onError) { @@ -4348,7 +4412,7 @@ var ts; break; } } - return token = 239 /* JsxText */; + return token = 240 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -4368,6 +4432,55 @@ var ts; } return token; } + function scanJSDocToken() { + if (pos >= end) { + return token = 1 /* EndOfFileToken */; + } + startPos = pos; + // Eat leading whitespace + var ch = text.charCodeAt(pos); + while (pos < end) { + ch = text.charCodeAt(pos); + if (isWhiteSpace(ch)) { + pos++; + } + else { + break; + } + } + tokenPos = pos; + switch (ch) { + case 64 /* at */: + return pos += 1, token = 55 /* AtToken */; + case 10 /* lineFeed */: + case 13 /* carriageReturn */: + return pos += 1, token = 4 /* NewLineTrivia */; + case 42 /* asterisk */: + return pos += 1, token = 37 /* AsteriskToken */; + case 123 /* openBrace */: + return pos += 1, token = 15 /* OpenBraceToken */; + case 125 /* closeBrace */: + return pos += 1, token = 16 /* CloseBraceToken */; + case 91 /* openBracket */: + return pos += 1, token = 19 /* OpenBracketToken */; + case 93 /* closeBracket */: + return pos += 1, token = 20 /* CloseBracketToken */; + case 61 /* equals */: + return pos += 1, token = 56 /* EqualsToken */; + case 44 /* comma */: + return pos += 1, token = 24 /* CommaToken */; + } + if (isIdentifierStart(ch, 2 /* Latest */)) { + pos++; + while (isIdentifierPart(text.charCodeAt(pos), 2 /* Latest */) && pos < end) { + pos++; + } + return token = 69 /* Identifier */; + } + else { + return pos += 1, token = 0 /* Unknown */; + } + } function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; @@ -4388,6 +4501,29 @@ var ts; } return result; } + function scanRange(start, length, callback) { + var saveEnd = end; + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var savePrecedingLineBreak = precedingLineBreak; + var saveTokenValue = tokenValue; + var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; + var saveTokenIsUnterminated = tokenIsUnterminated; + setText(text, start, length); + var result = callback(); + end = saveEnd; + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + precedingLineBreak = savePrecedingLineBreak; + tokenValue = saveTokenValue; + hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; + tokenIsUnterminated = saveTokenIsUnterminated; + return result; + } function lookAhead(callback) { return speculationHelper(callback, /*isLookahead*/ true); } @@ -4443,10 +4579,10 @@ var ts; var stringWriters = []; function getSingleLineStringWriter() { if (stringWriters.length === 0) { - var str = ""; - var writeText = function (text) { return str += text; }; + var str_1 = ""; + var writeText = function (text) { return str_1 += text; }; return { - string: function () { return str; }, + string: function () { return str_1; }, writeKeyword: writeText, writeOperator: writeText, writePunctuation: writeText, @@ -4456,10 +4592,10 @@ var ts; writeSymbol: writeText, // Completely ignore indentation for string writers. And map newlines to // a single space. - writeLine: function () { return str += " "; }, + writeLine: function () { return str_1 += " "; }, increaseIndent: function () { }, decreaseIndent: function () { }, - clear: function () { return str = ""; }, + clear: function () { return str_1 = ""; }, trackSymbol: function () { }, reportInaccessibleThisError: function () { } }; @@ -4510,33 +4646,45 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 64 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 268435456 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 128 /* HasAggregatedChildData */)) { + if (!(node.flags & 536870912 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 67108864 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 64 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 268435456 /* ThisNodeOrAnySubNodesHasError */; } - // Also mark that we've propogated the child information to this node. This way we can + // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.parserContextFlags |= 128 /* HasAggregatedChildData */; + node.flags |= 536870912 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 251 /* SourceFile */) { + while (node && node.kind !== 252 /* SourceFile */) { node = node.parent; } return node; } ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 196 /* Block */: + case 224 /* CaseBlock */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; function getStartPositionOfLine(line, sourceFile) { ts.Debug.assert(line >= 0); return ts.getLineStarts(sourceFile)[line]; @@ -4630,17 +4778,24 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 24576 /* BlockScoped */) !== 0 || + return (getCombinedNodeFlags(declaration) & 3072 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 221 /* ModuleDeclaration */ && + return node && node.kind === 222 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; + function isBlockScopedContainerTopLevel(node) { + return node.kind === 252 /* SourceFile */ || + node.kind === 222 /* ModuleDeclaration */ || + isFunctionLike(node) || + isFunctionBlock(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 2097152 /* GlobalAugmentation */); + return !!(module.flags & 131072 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -4651,9 +4806,9 @@ var ts; return false; } switch (node.parent.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: return isExternalModule(node.parent); - case 222 /* ModuleBlock */: + case 223 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !isExternalModule(node.parent.parent.parent); } return false; @@ -4668,15 +4823,15 @@ var ts; return current; } switch (current.kind) { - case 251 /* SourceFile */: - case 223 /* CaseBlock */: - case 247 /* CatchClause */: - case 221 /* ModuleDeclaration */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 252 /* SourceFile */: + case 224 /* CaseBlock */: + case 248 /* CatchClause */: + case 222 /* ModuleDeclaration */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: return current; - case 195 /* Block */: + case 196 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4689,9 +4844,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 214 /* VariableDeclaration */ && + declaration.kind === 215 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 247 /* CatchClause */; + declaration.parent.kind === 248 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4730,7 +4885,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 251 /* SourceFile */: + case 252 /* 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 @@ -4739,18 +4894,20 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: - case 221 /* ModuleDeclaration */: - case 220 /* EnumDeclaration */: - case 250 /* EnumMember */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 144 /* MethodDeclaration */: - case 219 /* TypeAliasDeclaration */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: + case 222 /* ModuleDeclaration */: + case 221 /* EnumDeclaration */: + case 251 /* EnumMember */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 220 /* TypeAliasDeclaration */: errorNode = node.name; break; } @@ -4774,15 +4931,15 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isDeclarationFile(file) { - return (file.flags & 4096 /* DeclarationFile */) !== 0; + return file.isDeclarationFile; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 220 /* EnumDeclaration */ && isConst(node); + return node.kind === 221 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 166 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 167 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -4797,29 +4954,33 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 214 /* VariableDeclaration */) { + if (node.kind === 215 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 215 /* VariableDeclarationList */) { + if (node && node.kind === 216 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 196 /* VariableStatement */) { + if (node && node.kind === 197 /* VariableStatement */) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 16384 /* Const */); + return !!(getCombinedNodeFlags(node) & 2048 /* Const */); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 8192 /* Let */); + return !!(getCombinedNodeFlags(node) & 1024 /* Let */); } ts.isLet = isLet; + function isSuperCallExpression(n) { + return n.kind === 172 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + } + ts.isSuperCallExpression = isSuperCallExpression; function isPrologueDirective(node) { - return node.kind === 198 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 199 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -4835,7 +4996,7 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 139 /* Parameter */ || node.kind === 138 /* TypeParameter */) ? + var commentRanges = (node.kind === 140 /* Parameter */ || node.kind === 139 /* TypeParameter */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -4850,37 +5011,37 @@ var ts; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (151 /* FirstTypeNode */ <= node.kind && node.kind <= 163 /* LastTypeNode */) { + if (152 /* FirstTypeNode */ <= node.kind && node.kind <= 164 /* LastTypeNode */) { return true; } switch (node.kind) { case 117 /* AnyKeyword */: - case 128 /* NumberKeyword */: - case 130 /* StringKeyword */: + case 129 /* NumberKeyword */: + case 131 /* StringKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: return true; case 103 /* VoidKeyword */: - return node.parent.kind !== 180 /* VoidExpression */; - case 191 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 181 /* VoidExpression */; + case 192 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 69 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 137 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 170 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - case 136 /* QualifiedName */: - case 169 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 137 /* QualifiedName */ || node.kind === 170 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 137 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: case 97 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 155 /* TypeQuery */) { + if (parent_1.kind === 156 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -4889,38 +5050,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 (151 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 163 /* LastTypeNode */) { + if (152 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 164 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: return node === parent_1.constraint; - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 139 /* Parameter */: - case 214 /* VariableDeclaration */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 140 /* Parameter */: + case 215 /* VariableDeclaration */: return node === parent_1.type; - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 145 /* Constructor */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 146 /* Constructor */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return node === parent_1.type; - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: return node === parent_1.type; - case 174 /* TypeAssertionExpression */: + case 175 /* TypeAssertionExpression */: return node === parent_1.type; - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -4934,23 +5095,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: return visitor(node); - case 223 /* CaseBlock */: - case 195 /* Block */: - case 199 /* IfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 208 /* WithStatement */: - case 209 /* SwitchStatement */: - case 244 /* CaseClause */: - case 245 /* DefaultClause */: - case 210 /* LabeledStatement */: - case 212 /* TryStatement */: - case 247 /* CatchClause */: + case 224 /* CaseBlock */: + case 196 /* Block */: + case 200 /* IfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 209 /* WithStatement */: + case 210 /* SwitchStatement */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: + case 211 /* LabeledStatement */: + case 213 /* TryStatement */: + case 248 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -4960,18 +5121,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 220 /* EnumDeclaration */: - case 218 /* InterfaceDeclaration */: - case 221 /* ModuleDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 221 /* EnumDeclaration */: + case 219 /* InterfaceDeclaration */: + case 222 /* ModuleDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 218 /* ClassDeclaration */: + case 190 /* 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. @@ -4979,7 +5140,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 137 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 138 /* 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); @@ -4998,14 +5159,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 166 /* BindingElement */: - case 250 /* EnumMember */: - case 139 /* Parameter */: - case 248 /* PropertyAssignment */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 249 /* ShorthandPropertyAssignment */: - case 214 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 251 /* EnumMember */: + case 140 /* Parameter */: + case 249 /* PropertyAssignment */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 250 /* ShorthandPropertyAssignment */: + case 215 /* VariableDeclaration */: return true; } } @@ -5013,11 +5174,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 146 /* GetAccessor */ || node.kind === 147 /* SetAccessor */); + return node && (node.kind === 147 /* GetAccessor */ || node.kind === 148 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 217 /* ClassDeclaration */ || node.kind === 189 /* ClassExpression */); + return node && (node.kind === 218 /* ClassDeclaration */ || node.kind === 190 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5026,32 +5187,32 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 145 /* Constructor */: - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 146 /* Constructor */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: return true; } } ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: return true; } return false; @@ -5059,30 +5220,34 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: return true; - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 195 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 196 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 144 /* MethodDeclaration */ && node.parent.kind === 168 /* ObjectLiteralExpression */; + return node && node.kind === 145 /* MethodDeclaration */ && node.parent.kind === 169 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1 /* Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0 /* This */; + } + ts.isThisTypePredicate = isThisTypePredicate; function getContainingFunction(node) { while (true) { node = node.parent; @@ -5108,7 +5273,7 @@ var ts; return undefined; } switch (node.kind) { - case 137 /* ComputedPropertyName */: + case 138 /* 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 @@ -5123,9 +5288,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 140 /* Decorator */: + case 141 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 139 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 140 /* 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; @@ -5136,26 +5301,26 @@ var ts; node = node.parent; } break; - case 177 /* ArrowFunction */: + case 178 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 221 /* ModuleDeclaration */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 220 /* EnumDeclaration */: - case 251 /* SourceFile */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 222 /* ModuleDeclaration */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 221 /* EnumDeclaration */: + case 252 /* SourceFile */: return node; } } @@ -5176,26 +5341,26 @@ var ts; return node; } switch (node.kind) { - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: node = node.parent; break; - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return node; - case 140 /* Decorator */: + case 141 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 139 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 140 /* 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; @@ -5210,15 +5375,24 @@ var ts; } } ts.getSuperContainer = getSuperContainer; + /** + * Determines whether a node is a property or element access expression for super. + */ + function isSuperPropertyOrElementAccess(node) { + return (node.kind === 170 /* PropertyAccessExpression */ + || node.kind === 171 /* ElementAccessExpression */) + && node.expression.kind === 95 /* SuperKeyword */; + } + ts.isSuperPropertyOrElementAccess = isSuperPropertyOrElementAccess; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 152 /* TypeReference */: + case 153 /* TypeReference */: return node.typeName; - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return node.expression; case 69 /* Identifier */: - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return node; } } @@ -5226,7 +5400,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 173 /* TaggedTemplateExpression */) { + if (node.kind === 174 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5235,25 +5409,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: // classes are valid targets return true; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 217 /* ClassDeclaration */; - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 144 /* MethodDeclaration */: + return node.parent.kind === 218 /* ClassDeclaration */; + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 145 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 217 /* ClassDeclaration */; - case 139 /* Parameter */: + && node.parent.kind === 218 /* ClassDeclaration */; + case 140 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return node.parent.body !== undefined - && (node.parent.kind === 145 /* Constructor */ - || node.parent.kind === 144 /* MethodDeclaration */ - || node.parent.kind === 147 /* SetAccessor */) - && node.parent.parent.kind === 217 /* ClassDeclaration */; + && (node.parent.kind === 146 /* Constructor */ + || node.parent.kind === 145 /* MethodDeclaration */ + || node.parent.kind === 148 /* SetAccessor */) + && node.parent.parent.kind === 218 /* ClassDeclaration */; } return false; } @@ -5264,11 +5438,11 @@ var ts; } ts.nodeIsDecorated = nodeIsDecorated; function isPropertyAccessExpression(node) { - return node.kind === 169 /* PropertyAccessExpression */; + return node.kind === 170 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 170 /* ElementAccessExpression */; + return node.kind === 171 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isExpression(node) { @@ -5278,42 +5452,42 @@ var ts; case 99 /* TrueKeyword */: case 84 /* FalseKeyword */: case 10 /* RegularExpressionLiteral */: - case 167 /* ArrayLiteralExpression */: - case 168 /* ObjectLiteralExpression */: - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 173 /* TaggedTemplateExpression */: - case 192 /* AsExpression */: - case 174 /* TypeAssertionExpression */: - case 175 /* ParenthesizedExpression */: - case 176 /* FunctionExpression */: - case 189 /* ClassExpression */: - case 177 /* ArrowFunction */: - case 180 /* VoidExpression */: - case 178 /* DeleteExpression */: - case 179 /* TypeOfExpression */: - case 182 /* PrefixUnaryExpression */: - case 183 /* PostfixUnaryExpression */: - case 184 /* BinaryExpression */: - case 185 /* ConditionalExpression */: - case 188 /* SpreadElementExpression */: - case 186 /* TemplateExpression */: + case 168 /* ArrayLiteralExpression */: + case 169 /* ObjectLiteralExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 174 /* TaggedTemplateExpression */: + case 193 /* AsExpression */: + case 175 /* TypeAssertionExpression */: + case 176 /* ParenthesizedExpression */: + case 177 /* FunctionExpression */: + case 190 /* ClassExpression */: + case 178 /* ArrowFunction */: + case 181 /* VoidExpression */: + case 179 /* DeleteExpression */: + case 180 /* TypeOfExpression */: + case 183 /* PrefixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: + case 185 /* BinaryExpression */: + case 186 /* ConditionalExpression */: + case 189 /* SpreadElementExpression */: + case 187 /* TemplateExpression */: case 11 /* NoSubstitutionTemplateLiteral */: - case 190 /* OmittedExpression */: - case 236 /* JsxElement */: - case 237 /* JsxSelfClosingElement */: - case 187 /* YieldExpression */: - case 181 /* AwaitExpression */: + case 191 /* OmittedExpression */: + case 237 /* JsxElement */: + case 238 /* JsxSelfClosingElement */: + case 188 /* YieldExpression */: + case 182 /* AwaitExpression */: return true; - case 136 /* QualifiedName */: - while (node.parent.kind === 136 /* QualifiedName */) { + case 137 /* QualifiedName */: + while (node.parent.kind === 137 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 155 /* TypeQuery */; + return node.parent.kind === 156 /* TypeQuery */; case 69 /* Identifier */: - if (node.parent.kind === 155 /* TypeQuery */) { + if (node.parent.kind === 156 /* TypeQuery */) { return true; } // fall through @@ -5322,47 +5496,47 @@ var ts; case 97 /* ThisKeyword */: var parent_2 = node.parent; switch (parent_2.kind) { - case 214 /* VariableDeclaration */: - case 139 /* Parameter */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 250 /* EnumMember */: - case 248 /* PropertyAssignment */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 140 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 251 /* EnumMember */: + case 249 /* PropertyAssignment */: + case 167 /* BindingElement */: return parent_2.initializer === node; - case 198 /* ExpressionStatement */: - case 199 /* IfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 207 /* ReturnStatement */: - case 208 /* WithStatement */: - case 209 /* SwitchStatement */: - case 244 /* CaseClause */: - case 211 /* ThrowStatement */: - case 209 /* SwitchStatement */: + case 199 /* ExpressionStatement */: + case 200 /* IfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 208 /* ReturnStatement */: + case 209 /* WithStatement */: + case 210 /* SwitchStatement */: + case 245 /* CaseClause */: + case 212 /* ThrowStatement */: + case 210 /* SwitchStatement */: return parent_2.expression === node; - case 202 /* ForStatement */: + case 203 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 215 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 216 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 215 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 216 /* VariableDeclarationList */) || forInStatement.expression === node; - case 174 /* TypeAssertionExpression */: - case 192 /* AsExpression */: + case 175 /* TypeAssertionExpression */: + case 193 /* AsExpression */: return node === parent_2.expression; - case 193 /* TemplateSpan */: + case 194 /* TemplateSpan */: return node === parent_2.expression; - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: return node === parent_2.expression; - case 140 /* Decorator */: - case 243 /* JsxExpression */: - case 242 /* JsxSpreadAttribute */: + case 141 /* Decorator */: + case 244 /* JsxExpression */: + case 243 /* JsxSpreadAttribute */: return true; - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5386,7 +5560,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */; + return node.kind === 225 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 236 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5395,7 +5569,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 235 /* ExternalModuleReference */; + return node.kind === 225 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 236 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5403,31 +5577,31 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.parserContextFlags & 32 /* JavaScriptFile */); + return node && !!(node.flags & 134217728 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; /** * Returns true if the node is a CallExpression to the identifier 'require' with - * exactly one string literal argument. + * exactly one argument. * This function does not test if the node is in a JavaScript file or not. */ - function isRequireCall(expression) { + function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - return expression.kind === 171 /* CallExpression */ && + var isRequire = expression.kind === 172 /* CallExpression */ && expression.expression.kind === 69 /* Identifier */ && expression.expression.text === "require" && - expression.arguments.length === 1 && - expression.arguments[0].kind === 9 /* StringLiteral */; + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9 /* StringLiteral */); } ts.isRequireCall = isRequireCall; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getSpecialPropertyAssignmentKind(expression) { - if (expression.kind !== 184 /* BinaryExpression */) { + if (expression.kind !== 185 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 169 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 170 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -5445,7 +5619,7 @@ var ts; else if (lhs.expression.kind === 97 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 169 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 170 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 69 /* Identifier */ && innerPropertyAccess.name.text === "prototype") { @@ -5456,19 +5630,19 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 225 /* ImportDeclaration */) { + if (node.kind === 226 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 224 /* ImportEqualsDeclaration */) { + if (node.kind === 225 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 235 /* ExternalModuleReference */) { + if (reference.kind === 236 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 231 /* ExportDeclaration */) { + if (node.kind === 232 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 221 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 222 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } @@ -5476,13 +5650,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 139 /* Parameter */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 249 /* ShorthandPropertyAssignment */: - case 248 /* PropertyAssignment */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 140 /* Parameter */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 250 /* ShorthandPropertyAssignment */: + case 249 /* PropertyAssignment */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5490,31 +5664,70 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 264 /* JSDocFunctionType */ && + return node.kind === 265 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 266 /* JSDocConstructorType */; + node.parameters[0].type.kind === 267 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind) { - if (node && node.jsDocComment) { - for (var _i = 0, _a = node.jsDocComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.kind === kind) { - return tag; - } + function getJSDocTag(node, kind, checkParentVariableStatement) { + if (!node) { + return undefined; + } + var jsDocComment = getJSDocComment(node, checkParentVariableStatement); + if (!jsDocComment) { + return undefined; + } + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === kind) { + return tag; } } } + function getJSDocComment(node, checkParentVariableStatement) { + if (node.jsDocComment) { + return node.jsDocComment; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + if (checkParentVariableStatement) { + var isInitializerOfVariableDeclarationInStatement = node.parent.kind === 215 /* VariableDeclaration */ && + node.parent.initializer === node && + node.parent.parent.parent.kind === 197 /* VariableStatement */; + var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; + if (variableStatementNode) { + return variableStatementNode.jsDocComment; + } + // Also recognize when the node is the RHS of an assignment expression + var parent_3 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_3 && parent_3.parent && + parent_3.kind === 185 /* BinaryExpression */ && + parent_3.operatorToken.kind === 56 /* EqualsToken */ && + parent_3.parent.kind === 199 /* ExpressionStatement */; + if (isSourceOfAssignmentExpressionStatement) { + return parent_3.parent.jsDocComment; + } + var isPropertyAssignmentExpression = parent_3 && parent_3.kind === 249 /* PropertyAssignment */; + if (isPropertyAssignmentExpression) { + return parent_3.jsDocComment; + } + } + return undefined; + } function getJSDocTypeTag(node) { - return getJSDocTag(node, 272 /* JSDocTypeTag */); + return getJSDocTag(node, 273 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 271 /* JSDocReturnTag */); + return getJSDocTag(node, 272 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 273 /* JSDocTemplateTag */); + return getJSDocTag(node, 274 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -5522,19 +5735,21 @@ var ts; // 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 === 270 /* JSDocParameterTag */) { - var parameterTag = t; + var jsDocComment = getJSDocComment(parameter.parent, /*checkParentVariableStatement*/ true); + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.kind === 271 /* JSDocParameterTag */) { + var parameterTag = tag; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { - return t; + return parameterTag; } } - }); + } } } + return undefined; } ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; function hasRestParameter(s) { @@ -5543,13 +5758,13 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { if (node) { - if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 265 /* JSDocVariadicType */) { + if (node.flags & 134217728 /* JavaScriptFile */) { + if (node.type && node.type.kind === 266 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 265 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 266 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5570,7 +5785,7 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 165 /* ArrayBindingPattern */ || node.kind === 164 /* ObjectBindingPattern */); + return !!node && (node.kind === 166 /* ArrayBindingPattern */ || node.kind === 165 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isNodeDescendentOf(node, ancestor) { @@ -5584,7 +5799,7 @@ var ts; ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (4 /* Ambient */ | 4096 /* DeclarationFile */)) { + if (node.flags & 2 /* Ambient */ || (node.kind === 252 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -5594,34 +5809,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 177 /* ArrowFunction */: - case 166 /* BindingElement */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 145 /* Constructor */: - case 220 /* EnumDeclaration */: - case 250 /* EnumMember */: - case 233 /* ExportSpecifier */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 146 /* GetAccessor */: - case 226 /* ImportClause */: - case 224 /* ImportEqualsDeclaration */: - case 229 /* ImportSpecifier */: - case 218 /* InterfaceDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 221 /* ModuleDeclaration */: - case 227 /* NamespaceImport */: - case 139 /* Parameter */: - case 248 /* PropertyAssignment */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 147 /* SetAccessor */: - case 249 /* ShorthandPropertyAssignment */: - case 219 /* TypeAliasDeclaration */: - case 138 /* TypeParameter */: - case 214 /* VariableDeclaration */: + case 178 /* ArrowFunction */: + case 167 /* BindingElement */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 146 /* Constructor */: + case 221 /* EnumDeclaration */: + case 251 /* EnumMember */: + case 234 /* ExportSpecifier */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 147 /* GetAccessor */: + case 227 /* ImportClause */: + case 225 /* ImportEqualsDeclaration */: + case 230 /* ImportSpecifier */: + case 219 /* InterfaceDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 222 /* ModuleDeclaration */: + case 228 /* NamespaceImport */: + case 140 /* Parameter */: + case 249 /* PropertyAssignment */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 148 /* SetAccessor */: + case 250 /* ShorthandPropertyAssignment */: + case 220 /* TypeAliasDeclaration */: + case 139 /* TypeParameter */: + case 215 /* VariableDeclaration */: return true; } return false; @@ -5629,25 +5844,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 206 /* BreakStatement */: - case 205 /* ContinueStatement */: - case 213 /* DebuggerStatement */: - case 200 /* DoStatement */: - case 198 /* ExpressionStatement */: - case 197 /* EmptyStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 202 /* ForStatement */: - case 199 /* IfStatement */: - case 210 /* LabeledStatement */: - case 207 /* ReturnStatement */: - case 209 /* SwitchStatement */: - case 211 /* ThrowStatement */: - case 212 /* TryStatement */: - case 196 /* VariableStatement */: - case 201 /* WhileStatement */: - case 208 /* WithStatement */: - case 230 /* ExportAssignment */: + case 207 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 214 /* DebuggerStatement */: + case 201 /* DoStatement */: + case 199 /* ExpressionStatement */: + case 198 /* EmptyStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 203 /* ForStatement */: + case 200 /* IfStatement */: + case 211 /* LabeledStatement */: + case 208 /* ReturnStatement */: + case 210 /* SwitchStatement */: + case 212 /* ThrowStatement */: + case 213 /* TryStatement */: + case 197 /* VariableStatement */: + case 202 /* WhileStatement */: + case 209 /* WithStatement */: + case 231 /* ExportAssignment */: return true; default: return false; @@ -5656,13 +5871,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 145 /* Constructor */: - case 142 /* PropertyDeclaration */: - case 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 143 /* MethodSignature */: - case 150 /* IndexSignature */: + case 146 /* Constructor */: + case 143 /* PropertyDeclaration */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 144 /* MethodSignature */: + case 151 /* IndexSignature */: return true; default: return false; @@ -5675,7 +5890,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 229 /* ImportSpecifier */ || parent.kind === 233 /* ExportSpecifier */) { + if (parent.kind === 230 /* ImportSpecifier */ || parent.kind === 234 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5690,31 +5905,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 250 /* EnumMember */: - case 248 /* PropertyAssignment */: - case 169 /* PropertyAccessExpression */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 251 /* EnumMember */: + case 249 /* PropertyAssignment */: + case 170 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 136 /* QualifiedName */) { + while (parent.kind === 137 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 155 /* TypeQuery */; + return parent.kind === 156 /* TypeQuery */; } return false; - case 166 /* BindingElement */: - case 229 /* ImportSpecifier */: + case 167 /* BindingElement */: + case 230 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 233 /* ExportSpecifier */: + case 234 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -5730,12 +5945,12 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 224 /* ImportEqualsDeclaration */ || - node.kind === 226 /* ImportClause */ && !!node.name || - node.kind === 227 /* NamespaceImport */ || - node.kind === 229 /* ImportSpecifier */ || - node.kind === 233 /* ExportSpecifier */ || - node.kind === 230 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; + return node.kind === 225 /* ImportEqualsDeclaration */ || + node.kind === 227 /* ImportClause */ && !!node.name || + node.kind === 228 /* NamespaceImport */ || + node.kind === 230 /* ImportSpecifier */ || + node.kind === 234 /* ExportSpecifier */ || + node.kind === 231 /* ExportAssignment */ && node.expression.kind === 69 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { @@ -5817,7 +6032,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 135 /* LastKeyword */; + return 70 /* FirstKeyword */ <= token && token <= 136 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -5844,7 +6059,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 137 /* ComputedPropertyName */ && + return name.kind === 138 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -5862,7 +6077,7 @@ var ts; if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 137 /* ComputedPropertyName */) { + if (name.kind === 138 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5894,6 +6109,7 @@ var ts; case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: + case 127 /* ReadonlyKeyword */: case 113 /* StaticKeyword */: return true; } @@ -5902,18 +6118,18 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 139 /* Parameter */; + return root.kind === 140 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 166 /* BindingElement */) { + while (node.kind === 167 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 221 /* ModuleDeclaration */ || n.kind === 251 /* SourceFile */; + return isFunctionLike(n) || n.kind === 222 /* ModuleDeclaration */ || n.kind === 252 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; /** @@ -5963,7 +6179,7 @@ var ts; } ts.cloneEntityName = cloneEntityName; function isQualifiedName(node) { - return node.kind === 136 /* QualifiedName */; + return node.kind === 137 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function nodeIsSynthesized(node) { @@ -6219,9 +6435,9 @@ var ts; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { - return compilerOptions.module ? + return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; + getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function forEachExpectedEmitFile(host, action, targetSourceFile) { @@ -6240,7 +6456,22 @@ var ts; } } function onSingleFileEmit(host, sourceFile) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, sourceFile.languageVariant === 1 /* JSX */ && options.jsx === 1 /* Preserve */ ? ".jsx" : ".js"); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + var extension = ".js"; + if (options.jsx === 1 /* Preserve */) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === 1 /* JSX */) { + // TypeScript source file preserving JSX syntax + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); var emitFileNames = { jsFilePath: jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), @@ -6293,7 +6524,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 145 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 146 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6310,10 +6541,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 146 /* GetAccessor */) { + if (accessor.kind === 147 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 147 /* SetAccessor */) { + else if (accessor.kind === 148 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6322,8 +6553,8 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 146 /* GetAccessor */ || member.kind === 147 /* SetAccessor */) - && (member.flags & 64 /* Static */) === (accessor.flags & 64 /* Static */)) { + if ((member.kind === 147 /* GetAccessor */ || member.kind === 148 /* SetAccessor */) + && (member.flags & 32 /* Static */) === (accessor.flags & 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -6333,10 +6564,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 146 /* GetAccessor */ && !getAccessor) { + if (member.kind === 147 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 147 /* SetAccessor */ && !setAccessor) { + if (member.kind === 148 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6403,7 +6634,7 @@ var ts; } if (leadingComments) { var detachedComments = []; - var lastComment; + var lastComment = void 0; for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { var comment = leadingComments_1[_i]; if (lastComment) { @@ -6444,7 +6675,7 @@ var ts; if (text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, comment.pos); var lineCount = lineMap.length; - var firstCommentLineIndent; + var firstCommentLineIndent = void 0; for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { var nextLineStart = (currentLine + 1) === lineCount ? text.length + 1 @@ -6529,16 +6760,17 @@ var ts; } function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 64 /* Static */; - case 112 /* PublicKeyword */: return 8 /* Public */; - case 111 /* ProtectedKeyword */: return 32 /* Protected */; - case 110 /* PrivateKeyword */: return 16 /* Private */; + case 113 /* StaticKeyword */: return 32 /* Static */; + case 112 /* PublicKeyword */: return 4 /* Public */; + case 111 /* ProtectedKeyword */: return 16 /* Protected */; + case 110 /* PrivateKeyword */: return 8 /* Private */; case 115 /* AbstractKeyword */: return 128 /* Abstract */; - case 82 /* ExportKeyword */: return 2 /* Export */; - case 122 /* DeclareKeyword */: return 4 /* Ambient */; - case 74 /* ConstKeyword */: return 16384 /* Const */; + case 82 /* ExportKeyword */: return 1 /* Export */; + case 122 /* DeclareKeyword */: return 2 /* Ambient */; + case 74 /* ConstKeyword */: return 2048 /* Const */; case 77 /* DefaultKeyword */: return 512 /* Default */; case 118 /* AsyncKeyword */: return 256 /* Async */; + case 127 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0; } @@ -6546,24 +6778,24 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: - case 172 /* NewExpression */: - case 171 /* CallExpression */: - case 236 /* JsxElement */: - case 237 /* JsxSelfClosingElement */: - case 173 /* TaggedTemplateExpression */: - case 167 /* ArrayLiteralExpression */: - case 175 /* ParenthesizedExpression */: - case 168 /* ObjectLiteralExpression */: - case 189 /* ClassExpression */: - case 176 /* FunctionExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 173 /* NewExpression */: + case 172 /* CallExpression */: + case 237 /* JsxElement */: + case 238 /* JsxSelfClosingElement */: + case 174 /* TaggedTemplateExpression */: + case 168 /* ArrayLiteralExpression */: + case 176 /* ParenthesizedExpression */: + case 169 /* ObjectLiteralExpression */: + case 190 /* ClassExpression */: + case 177 /* FunctionExpression */: case 69 /* Identifier */: case 10 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 11 /* NoSubstitutionTemplateLiteral */: - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: case 84 /* FalseKeyword */: case 93 /* NullKeyword */: case 97 /* ThisKeyword */: @@ -6580,7 +6812,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 191 /* ExpressionWithTypeArguments */ && + return node.kind === 192 /* ExpressionWithTypeArguments */ && node.parent.token === 83 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } @@ -6603,16 +6835,16 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 137 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 170 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 168 /* ObjectLiteralExpression */) { + if (kind === 169 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 167 /* ArrayLiteralExpression */) { + if (kind === 168 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -6726,7 +6958,7 @@ var ts; else if (i + 2 >= length) { byte4 = 64; } - // Write to the ouput + // Write to the output result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); i += 3; } @@ -6912,9 +7144,9 @@ var ts; // . | \ // ----------------------------------------------------------------------*-------------------------------- // - // (Note the dots represent the newly inferrred start. + // (Note the dots represent the newly inferred start. // Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the - // absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see + // absolute positions at the asterisks, and the relative change between the dollar signs. Basically, we see // which if the two $'s precedes the other, and we move that one forward until they line up. in this case that // means: // @@ -6937,8 +7169,8 @@ var ts; // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started // that's the same as if we started at char 80 instead of 60. // - // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter - // than pusing the first edit forward to match the second, we'll push the second edit forward to match the + // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rather + // than pushing the first edit forward to match the second, we'll push the second edit forward to match the // first. // // In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange @@ -6967,9 +7199,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 138 /* TypeParameter */) { + if (d && d.kind === 139 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 218 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 219 /* InterfaceDeclaration */) { return current; } } @@ -6977,7 +7209,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 145 /* Constructor */ && ts.isClassLike(node.parent.parent); + return node.flags & 28 /* AccessibilityModifier */ && node.parent.kind === 146 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; })(ts || (ts = {})); @@ -6989,7 +7221,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 251 /* SourceFile */) { + if (kind === 252 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else { @@ -7032,26 +7264,26 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 249 /* ShorthandPropertyAssignment */: + case 250 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 139 /* Parameter */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 248 /* PropertyAssignment */: - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: + case 140 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 249 /* PropertyAssignment */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7060,24 +7292,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7088,302 +7320,319 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 152 /* TypeReference */: + case 153 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 156 /* TypeLiteral */: + case 157 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 157 /* ArrayType */: + case 158 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 158 /* TupleType */: + case 159 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 159 /* UnionType */: - case 160 /* IntersectionType */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 169 /* PropertyAccessExpression */: + case 170 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 170 /* ElementAccessExpression */: + case 171 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 174 /* TypeAssertionExpression */: + case 175 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 178 /* DeleteExpression */: + case 179 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 179 /* TypeOfExpression */: + case 180 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 180 /* VoidExpression */: + case 181 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 181 /* AwaitExpression */: + case 182 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 183 /* PostfixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 192 /* AsExpression */: + case 193 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 188 /* SpreadElementExpression */: + case 189 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 195 /* Block */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 215 /* VariableDeclarationList */: + case 216 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 199 /* IfStatement */: + case 200 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 200 /* DoStatement */: + case 201 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 202 /* ForStatement */: + case 203 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 203 /* ForInStatement */: + case 204 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 204 /* ForOfStatement */: + case 205 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 205 /* ContinueStatement */: - case 206 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 207 /* BreakStatement */: return visitNode(cbNode, node.label); - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 208 /* WithStatement */: + case 209 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 223 /* CaseBlock */: + case 224 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 244 /* CaseClause */: + case 245 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 245 /* DefaultClause */: + case 246 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 211 /* ThrowStatement */: + case 212 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 212 /* TryStatement */: + case 213 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 140 /* Decorator */: + case 141 /* Decorator */: return visitNode(cbNode, node.expression); - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* 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 218 /* InterfaceDeclaration */: + case 219 /* 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 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 226 /* ImportClause */: + case 227 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 227 /* NamespaceImport */: + case 228 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 228 /* NamedImports */: - case 232 /* NamedExports */: + case 229 /* NamedImports */: + case 233 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 229 /* ImportSpecifier */: - case 233 /* ExportSpecifier */: + case 230 /* ImportSpecifier */: + case 234 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 193 /* TemplateSpan */: + case 194 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 246 /* HeritageClause */: + case 247 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 235 /* ExternalModuleReference */: + case 236 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 234 /* MissingDeclaration */: + case 235 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 236 /* JsxElement */: + case 237 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 237 /* JsxSelfClosingElement */: - case 238 /* JsxOpeningElement */: + case 238 /* JsxSelfClosingElement */: + case 239 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 241 /* JsxAttribute */: + case 242 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 242 /* JsxSpreadAttribute */: + case 243 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 240 /* JsxClosingElement */: + case 241 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 252 /* JSDocTypeExpression */: + case 253 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 256 /* JSDocUnionType */: + case 257 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 257 /* JSDocTupleType */: + case 258 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 255 /* JSDocArrayType */: + case 256 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 259 /* JSDocNonNullableType */: + case 260 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 258 /* JSDocNullableType */: + case 259 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 260 /* JSDocRecordType */: + case 261 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 262 /* JSDocTypeReference */: + case 263 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 263 /* JSDocOptionalType */: + case 264 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 264 /* JSDocFunctionType */: + case 265 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 265 /* JSDocVariadicType */: + case 266 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 266 /* JSDocConstructorType */: + case 267 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 267 /* JSDocThisType */: + case 268 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 261 /* JSDocRecordMember */: + case 262 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 268 /* JSDocComment */: + case 269 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 270 /* JSDocParameterTag */: + case 271 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 271 /* JSDocReturnTag */: + case 272 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 272 /* JSDocTypeTag */: + case 273 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 273 /* JSDocTemplateTag */: + case 274 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } ts.forEachChild = forEachChild; - function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { + function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); ts.parseTime += new Date().getTime() - start; return result; } ts.createSourceFile = createSourceFile; + /* @internal */ + function getScriptKindFromFileName(fileName) { + var ext = fileName.substr(fileName.lastIndexOf(".")); + switch (ext.toLowerCase()) { + case ".js": + return 1 /* JS */; + case ".jsx": + return 2 /* JSX */; + case ".ts": + return 3 /* TS */; + case ".tsx": + return 4 /* TSX */; + default: + return 3 /* TS */; + } + } + ts.getScriptKindFromFileName = getScriptKindFromFileName; // Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter // indicates what changed between the 'text' that this SourceFile has and the 'newText'. // The SourceFile will be created with the compiler attempting to reuse as many nodes from @@ -7416,7 +7665,7 @@ var ts; // 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 */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; + var disallowInAndDecoratorContext = 4194304 /* DisallowInContext */ | 16777216 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; var SourceFileConstructor; @@ -7504,19 +7753,24 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes) { - var isJavaScriptFile = ts.hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0; - initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor); - var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes); + function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + // Using scriptKind as a condition handles both: + // - 'scriptKind' is unspecified and thus it is `undefined` + // - 'scriptKind' is set and it is `Unknown` (0) + // If the 'scriptKind' is 'undefined' or 'Unknown' then attempt + // to get the ScriptKind from the file name. + scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName); + initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; } Parser.parseSourceFile = parseSourceFile; - function getLanguageVariant(fileName) { + function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return ts.fileExtensionIs(fileName, ".tsx") || ts.fileExtensionIs(fileName, ".jsx") ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ ? 1 /* JSX */ : 0 /* Standard */; } - function initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor) { + function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor(); sourceText = _sourceText; @@ -7526,30 +7780,28 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = isJavaScriptFile ? 32 /* JavaScriptFile */ : 0 /* None */; + contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 134217728 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(getLanguageVariant(fileName)); + scanner.setLanguageVariant(getLanguageVariant(scriptKind)); } function clearState() { // Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. scanner.setText(""); scanner.setOnError(undefined); - // Clear any data. We don't want to accidently hold onto it for too long. + // Clear any data. We don't want to accidentally hold onto it for too long. parseDiagnostics = undefined; sourceFile = undefined; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; } - function parseSourceFileWorker(fileName, languageVersion, setParentNodes) { - sourceFile = createSourceFile(fileName, languageVersion); - if (contextFlags & 32 /* JavaScriptFile */) { - sourceFile.parserContextFlags = 32 /* JavaScriptFile */; - } + function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { + sourceFile = createSourceFile(fileName, languageVersion, scriptKind); + sourceFile.flags = contextFlags; // Prime the scanner. token = nextToken(); processReferenceComments(sourceFile); @@ -7564,40 +7816,22 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - // If this is a javascript file, proactively see if we can get JSDoc comments for - // relevant nodes in the file. We'll use these to provide typing informaion if they're - // available. - if (ts.isSourceFileJavaScript(sourceFile)) { - addJSDocComments(); - } return sourceFile; } - function addJSDocComments() { - forEachChild(sourceFile, visit); - return; - function visit(node) { - // Add additional cases as necessary depending on how we see JSDoc comments used - // in the wild. - switch (node.kind) { - case 196 /* VariableStatement */: - case 216 /* FunctionDeclaration */: - case 139 /* Parameter */: - addJSDocComment(node); - } - forEachChild(node, visit); - } - } function addJSDocComment(node) { - var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (jsDocComment) { - node.jsDocComment = jsDocComment; + if (contextFlags & 134217728 /* JavaScriptFile */) { + var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (jsDocComment) { + node.jsDocComment = jsDocComment; + } } } } + return node; } function fixupParentReferences(sourceFile) { // normally parent references are set during binding. However, for clients that only need @@ -7621,17 +7855,18 @@ var ts; } } Parser.fixupParentReferences = fixupParentReferences; - function createSourceFile(fileName, languageVersion) { + function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(251 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(252 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 /* DeclarationFile */ : 0; - sourceFile.languageVariant = getLanguageVariant(sourceFile.fileName); + sourceFile.languageVariant = getLanguageVariant(scriptKind); + sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts"); + sourceFile.scriptKind = scriptKind; return sourceFile; } function setContextFlag(val, flag) { @@ -7643,16 +7878,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 1 /* DisallowIn */); + setContextFlag(val, 4194304 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 2 /* Yield */); + setContextFlag(val, 8388608 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 4 /* Decorator */); + setContextFlag(val, 16777216 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 8 /* Await */); + setContextFlag(val, 33554432 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -7693,40 +7928,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(1 /* DisallowIn */, func); + return doOutsideOfContext(4194304 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(1 /* DisallowIn */, func); + return doInsideOfContext(4194304 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(2 /* Yield */, func); + return doInsideOfContext(8388608 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(4 /* Decorator */, func); + return doInsideOfContext(16777216 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(8 /* Await */, func); + return doInsideOfContext(33554432 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(8 /* Await */, func); + return doOutsideOfContext(33554432 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(2 /* Yield */ | 8 /* Await */, func); + return doInsideOfContext(8388608 /* YieldContext */ | 33554432 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(2 /* Yield */); + return inContext(8388608 /* YieldContext */); } function inDisallowInContext() { - return inContext(1 /* DisallowIn */); + return inContext(4194304 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(4 /* Decorator */); + return inContext(16777216 /* DecoratorContext */); } function inAwaitContext() { - return inContext(8 /* Await */); + return inContext(33554432 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -7900,14 +8135,14 @@ var ts; function finishNode(node, end) { node.end = end === undefined ? scanner.getStartPos() : end; if (contextFlags) { - node.parserContextFlags = contextFlags; + node.flags |= contextFlags; } // Keep track on the node if we encountered an error while parsing it. If we did, then // we cannot reuse the node incrementally. Once we've marked this node, clear out the // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16 /* ThisNodeHasError */; + node.flags |= 67108864 /* ThisNodeHasError */; } return node; } @@ -7976,7 +8211,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(137 /* ComputedPropertyName */); + var node = createNode(138 /* 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 @@ -8049,7 +8284,7 @@ var ts; case 2 /* SwitchClauses */: return token === 71 /* CaseKeyword */ || token === 77 /* DefaultKeyword */; case 4 /* TypeMembers */: - return isStartOfTypeMember(); + return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant @@ -8289,20 +8524,20 @@ var ts; // We can only reuse a node if it was parsed under the same strict mode that we're // currently in. i.e. if we originally parsed a node in non-strict mode, but then // the user added 'using strict' at the top of the file, then we can't use that node - // again as the presense of strict mode may cause us to parse the tokens in the file - // differetly. + // again as the presence of strict mode may cause us to parse the tokens in the file + // differently. // // Note: we *can* reuse tokens when the strict mode changes. That's because tokens // are unaffected by strict mode. It's just the parser will decide what to do with it // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 31 /* ParserGeneratedFlags */; + var nodeContextFlags = node.flags & 62914560 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } // Ok, we have a node that looks like it could be reused. Now verify that it is valid - // in the currest list parsing context that we're currently at. + // in the current list parsing context that we're currently at. if (!canReuseNode(node, parsingContext)) { return undefined; } @@ -8377,14 +8612,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 145 /* Constructor */: - case 150 /* IndexSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 142 /* PropertyDeclaration */: - case 194 /* SemicolonClassElement */: + case 146 /* Constructor */: + case 151 /* IndexSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 143 /* PropertyDeclaration */: + case 195 /* SemicolonClassElement */: return true; - case 144 /* MethodDeclaration */: + case 145 /* 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. @@ -8399,8 +8634,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 244 /* CaseClause */: - case 245 /* DefaultClause */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: return true; } } @@ -8409,58 +8644,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 216 /* FunctionDeclaration */: - case 196 /* VariableStatement */: - case 195 /* Block */: - case 199 /* IfStatement */: - case 198 /* ExpressionStatement */: - case 211 /* ThrowStatement */: - case 207 /* ReturnStatement */: - case 209 /* SwitchStatement */: - case 206 /* BreakStatement */: - case 205 /* ContinueStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 202 /* ForStatement */: - case 201 /* WhileStatement */: - case 208 /* WithStatement */: - case 197 /* EmptyStatement */: - case 212 /* TryStatement */: - case 210 /* LabeledStatement */: - case 200 /* DoStatement */: - case 213 /* DebuggerStatement */: - case 225 /* ImportDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 231 /* ExportDeclaration */: - case 230 /* ExportAssignment */: - case 221 /* ModuleDeclaration */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 219 /* TypeAliasDeclaration */: + case 217 /* FunctionDeclaration */: + case 197 /* VariableStatement */: + case 196 /* Block */: + case 200 /* IfStatement */: + case 199 /* ExpressionStatement */: + case 212 /* ThrowStatement */: + case 208 /* ReturnStatement */: + case 210 /* SwitchStatement */: + case 207 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 203 /* ForStatement */: + case 202 /* WhileStatement */: + case 209 /* WithStatement */: + case 198 /* EmptyStatement */: + case 213 /* TryStatement */: + case 211 /* LabeledStatement */: + case 201 /* DoStatement */: + case 214 /* DebuggerStatement */: + case 226 /* ImportDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 232 /* ExportDeclaration */: + case 231 /* ExportAssignment */: + case 222 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 220 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 250 /* EnumMember */; + return node.kind === 251 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 149 /* ConstructSignature */: - case 143 /* MethodSignature */: - case 150 /* IndexSignature */: - case 141 /* PropertySignature */: - case 148 /* CallSignature */: + case 150 /* ConstructSignature */: + case 144 /* MethodSignature */: + case 151 /* IndexSignature */: + case 142 /* PropertySignature */: + case 149 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 214 /* VariableDeclaration */) { + if (node.kind !== 215 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8481,7 +8716,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 139 /* Parameter */) { + if (node.kind !== 140 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8529,7 +8764,7 @@ var ts; } ; // Parses a comma-delimited list of elements - function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimeter) { + function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; @@ -8554,7 +8789,7 @@ var ts; // 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 === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -8598,7 +8833,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(21 /* DotToken */)) { - var node = createNode(136 /* QualifiedName */, entity.pos); + var node = createNode(137 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8637,7 +8872,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(186 /* TemplateExpression */); + var template = createNode(187 /* TemplateExpression */); template.head = parseTemplateLiteralFragment(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8650,7 +8885,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(193 /* TemplateSpan */); + var span = createNode(194 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 16 /* CloseBraceToken */) { @@ -8664,7 +8899,7 @@ var ts; return finishNode(span); } function parseStringLiteralTypeNode() { - return parseLiteralLikeNode(163 /* StringLiteralType */, /*internName*/ true); + return parseLiteralLikeNode(164 /* StringLiteralType */, /*internName*/ true); } function parseLiteralNode(internName) { return parseLiteralLikeNode(token, internName); @@ -8694,40 +8929,40 @@ var ts; if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 32768 /* OctalLiteral */; + node.isOctalLiteral = true; } return node; } // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(152 /* TypeReference */, typeName.pos); + var node = createNode(153 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } - function parseTypePredicate(lhs) { + function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(151 /* TypePredicate */, lhs.pos); + var node = createNode(152 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(162 /* ThisType */); + var node = createNode(163 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(155 /* TypeQuery */); + var node = createNode(156 /* TypeQuery */); parseExpected(101 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(138 /* TypeParameter */); + var node = createNode(139 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(83 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -8771,7 +9006,7 @@ var ts; } } function parseParameter() { - var node = createNode(139 /* Parameter */); + var node = createNode(140 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); @@ -8800,7 +9035,7 @@ var ts; // contexts. In addition, parameter initializers are semantically disallowed in // overload signatures. So parameter initializers are transitively disallowed in // ambient contexts. - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseBindingElementInitializer(inParameter) { return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); @@ -8865,7 +9100,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 149 /* ConstructSignature */) { + if (kind === 150 /* ConstructSignature */) { parseExpected(92 /* NewKeyword */); } fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -8929,7 +9164,7 @@ var ts; return token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(150 /* IndexSignature */, fullStart); + var node = createNode(151 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); @@ -8937,22 +9172,23 @@ var ts; parseTypeMemberSemicolon(); return finishNode(node); } - function parsePropertyOrMethodSignature() { - var fullStart = scanner.getStartPos(); + function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); var questionToken = parseOptionalToken(53 /* QuestionToken */); if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { - var method = createNode(143 /* MethodSignature */, fullStart); + var method = createNode(144 /* MethodSignature */, fullStart); + setModifiers(method, modifiers); method.name = name; method.questionToken = questionToken; - // Method signatues don't exist in expression contexts. So they have neither + // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(141 /* PropertySignature */, fullStart); + var property = createNode(142 /* PropertySignature */, fullStart); + setModifiers(property, modifiers); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8966,86 +9202,57 @@ var ts; return finishNode(property); } } - function isStartOfTypeMember() { - switch (token) { - case 17 /* OpenParenToken */: - case 25 /* LessThanToken */: - case 19 /* OpenBracketToken */: - return true; - default: - if (ts.isModifierKind(token)) { - var result = lookAhead(isStartOfIndexSignatureDeclaration); - if (result) { - return result; - } - } - return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); + function isTypeMemberStart() { + var idToken; + // Return true if we have the start of a signature member + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + return true; } - } - function isStartOfIndexSignatureDeclaration() { + // Eat up all modifiers, but hold on to the last one in case it is actually an identifier while (ts.isModifierKind(token)) { + idToken = token; nextToken(); } - return isIndexSignature(); - } - function isTypeMemberWithLiteralPropertyName() { - nextToken(); - return token === 17 /* OpenParenToken */ || - token === 25 /* LessThanToken */ || - token === 53 /* QuestionToken */ || - token === 54 /* ColonToken */ || - canParseSemicolon(); + // Index signatures and computed property names are type members + if (token === 19 /* OpenBracketToken */) { + return true; + } + // Try to get the first property-like token following all modifiers + if (isLiteralPropertyName()) { + idToken = token; + nextToken(); + } + // If we were able to get any potential identifier, check that it is + // the start of a member declaration + if (idToken) { + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 53 /* QuestionToken */ || + token === 54 /* ColonToken */ || + canParseSemicolon(); + } + return false; } function parseTypeMember() { - switch (token) { - case 17 /* OpenParenToken */: - case 25 /* LessThanToken */: - return parseSignatureMember(148 /* CallSignature */); - case 19 /* OpenBracketToken */: - // Indexer or computed property - return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) - : parsePropertyOrMethodSignature(); - case 92 /* NewKeyword */: - if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(149 /* ConstructSignature */); - } - // fall through. - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - return parsePropertyOrMethodSignature(); - default: - // Index declaration as allowed as a type member. But as per the grammar, - // they also allow modifiers. So we have to check for an index declaration - // that might be following modifiers. This ensures that things work properly - // when incrementally parsing as the parser will produce the Index declaration - // if it has the same text regardless of whether it is inside a class or an - // object type. - if (ts.isModifierKind(token)) { - var result = tryParse(parseIndexSignatureWithModifiers); - if (result) { - return result; - } - } - if (ts.tokenIsIdentifierOrKeyword(token)) { - return parsePropertyOrMethodSignature(); - } + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + return parseSignatureMember(149 /* CallSignature */); } - } - function parseIndexSignatureWithModifiers() { - var fullStart = scanner.getStartPos(); - var decorators = parseDecorators(); + if (token === 92 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(150 /* ConstructSignature */); + } + var fullStart = getNodePos(); var modifiers = parseModifiers(); - return isIndexSignature() - ? parseIndexSignatureDeclaration(fullStart, decorators, modifiers) - : undefined; + if (isIndexSignature()) { + return parseIndexSignatureDeclaration(fullStart, /*decorators*/ undefined, modifiers); + } + return parsePropertyOrMethodSignature(fullStart, modifiers); } function isStartOfConstructSignature() { nextToken(); return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(156 /* TypeLiteral */); + var node = createNode(157 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -9061,12 +9268,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(158 /* TupleType */); + var node = createNode(159 /* TupleType */); node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(161 /* ParenthesizedType */); + var node = createNode(162 /* ParenthesizedType */); parseExpected(17 /* OpenParenToken */); node.type = parseType(); parseExpected(18 /* CloseParenToken */); @@ -9074,7 +9281,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 154 /* ConstructorType */) { + if (kind === 155 /* ConstructorType */) { parseExpected(92 /* NewKeyword */); } fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -9087,10 +9294,10 @@ var ts; function parseNonArrayType() { switch (token) { case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -9101,7 +9308,7 @@ var ts; case 97 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); if (token === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { - return parseTypePredicate(thisKeyword); + return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; @@ -9122,10 +9329,10 @@ var ts; function isStartOfType() { switch (token) { case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: case 103 /* VoidKeyword */: case 97 /* ThisKeyword */: case 101 /* TypeOfKeyword */: @@ -9151,7 +9358,7 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { parseExpected(20 /* CloseBracketToken */); - var node = createNode(157 /* ArrayType */, type.pos); + var node = createNode(158 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9173,10 +9380,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(160 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + return parseUnionOrIntersectionType(161 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(159 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + return parseUnionOrIntersectionType(160 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); } function isStartOfFunctionType() { if (token === 25 /* LessThanToken */) { @@ -9184,6 +9391,23 @@ var ts; } return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } + function skipParameterStart() { + if (ts.isModifierKind(token)) { + // Skip modifiers + parseModifiers(); + } + if (isIdentifier()) { + nextToken(); + return true; + } + if (token === 19 /* OpenBracketToken */ || token === 15 /* OpenBraceToken */) { + // Return true if we can parse an array or object binding pattern with no errors + var previousErrorCount = parseDiagnostics.length; + parseIdentifierOrPattern(); + return previousErrorCount === parseDiagnostics.length; + } + return false; + } function isUnambiguouslyStartOfFunctionType() { nextToken(); if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { @@ -9191,22 +9415,21 @@ var ts; // ( ... return true; } - if (isIdentifier() || ts.isModifierKind(token)) { - nextToken(); + if (skipParameterStart()) { + // We successfully skipped modifiers (if any) and an identifier or binding pattern, + // now see if we have something that indicates a parameter declaration if (token === 54 /* ColonToken */ || token === 24 /* CommaToken */ || - token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */ || - isIdentifier() || ts.isModifierKind(token)) { - // ( id : - // ( id , - // ( id ? - // ( id = - // ( modifier id + token === 53 /* QuestionToken */ || token === 56 /* EqualsToken */) { + // ( xxx : + // ( xxx , + // ( xxx ? + // ( xxx = return true; } if (token === 18 /* CloseParenToken */) { nextToken(); if (token === 34 /* EqualsGreaterThanToken */) { - // ( id ) => + // ( xxx ) => return true; } } @@ -9217,7 +9440,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(151 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(152 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -9236,14 +9459,14 @@ var ts; function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(10 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(41943040 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(153 /* FunctionType */); + return parseFunctionOrConstructorType(154 /* FunctionType */); } if (token === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(154 /* ConstructorType */); + return parseFunctionOrConstructorType(155 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -9408,7 +9631,7 @@ var ts; } function isYieldExpression() { if (token === 114 /* YieldKeyword */) { - // If we have a 'yield' keyword, and htis is a context where yield expressions are + // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { return true; @@ -9426,7 +9649,7 @@ var ts; // // for now we just check if the next token is an identifier. More heuristics // can be added here later as necessary. We just need to make sure that we - // don't accidently consume something legal. + // don't accidentally consume something legal. return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine); } return false; @@ -9436,7 +9659,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(187 /* YieldExpression */); + var node = createNode(188 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -9450,14 +9673,14 @@ var ts; } else { // if the next token is not on the same line as yield. or we don't have an '*' or - // the start of an expressin, then this is just a simple "yield" expression. + // the start of an expression, then this is just a simple "yield" expression. return finishNode(node); } } function parseSimpleArrowFunctionExpression(identifier) { ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(177 /* ArrowFunction */, identifier.pos); - var parameter = createNode(139 /* Parameter */, identifier.pos); + var node = createNode(178 /* ArrowFunction */, identifier.pos); + var parameter = createNode(140 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; @@ -9609,7 +9832,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(177 /* ArrowFunction */); + var node = createNode(178 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 256 /* Async */); // Arrow functions are never generators. @@ -9675,7 +9898,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(185 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(186 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -9688,7 +9911,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 135 /* OfKeyword */; + return t === 90 /* InKeyword */ || t === 136 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9699,7 +9922,7 @@ var ts; // Check the precedence to see if we should "take" this operator // - For left associative operator (all operator but **), consume the operator, // recursively call the function below, and parse binaryExpression as a rightOperand - // of the caller if the new precendence of the operator is greater then or equal to the current precendence. + // of the caller if the new precedence of the operator is greater then or equal to the current precedence. // For example: // a - b - c; // ^token; leftOperand = b. Return b to the caller as a rightOperand @@ -9708,8 +9931,8 @@ var ts; // a - b * c; // ^token; leftOperand = b. Return b * c to the caller as a rightOperand // - For right associative operator (**), consume the operator, recursively call the function - // and parse binaryExpression as a rightOperand of the caller if the new precendence of - // the operator is strictly grater than the current precendence + // and parse binaryExpression as a rightOperand of the caller if the new precedence of + // the operator is strictly grater than the current precedence // For example: // a ** b ** c; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand @@ -9796,39 +10019,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(184 /* BinaryExpression */, left.pos); + var node = createNode(185 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(192 /* AsExpression */, left.pos); + var node = createNode(193 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(182 /* PrefixUnaryExpression */); + var node = createNode(183 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(178 /* DeleteExpression */); + var node = createNode(179 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(179 /* TypeOfExpression */); + var node = createNode(180 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(180 /* VoidExpression */); + var node = createNode(181 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -9844,7 +10067,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(181 /* AwaitExpression */); + var node = createNode(182 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -9870,7 +10093,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token === 38 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 174 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 175 /* TypeAssertionExpression */) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -9926,7 +10149,7 @@ var ts; */ function isIncrementExpression() { // This function is called inside parseUnaryExpression to decide - // whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly + // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token) { case 35 /* PlusToken */: case 36 /* MinusToken */: @@ -9960,7 +10183,7 @@ var ts; */ function parseIncrementExpression() { if (token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) { - var node = createNode(182 /* PrefixUnaryExpression */); + var node = createNode(183 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -9973,7 +10196,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token === 41 /* PlusPlusToken */ || token === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(183 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(184 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -10077,7 +10300,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(169 /* PropertyAccessExpression */, expression.pos); + var node = createNode(170 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10096,8 +10319,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 238 /* JsxOpeningElement */) { - var node = createNode(236 /* JsxElement */, opening.pos); + if (opening.kind === 239 /* JsxOpeningElement */) { + var node = createNode(237 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -10107,7 +10330,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 237 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 238 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -10122,7 +10345,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(184 /* BinaryExpression */, result.pos); + var badNode = createNode(185 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -10134,13 +10357,13 @@ var ts; return result; } function parseJsxText() { - var node = createNode(239 /* JsxText */, scanner.getStartPos()); + var node = createNode(240 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 239 /* JsxText */: + case 240 /* JsxText */: return parseJsxText(); case 15 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); @@ -10182,7 +10405,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(238 /* JsxOpeningElement */, fullStart); + node = createNode(239 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -10194,7 +10417,7 @@ var ts; parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(237 /* JsxSelfClosingElement */, fullStart); + node = createNode(238 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10205,7 +10428,7 @@ var ts; var elementName = parseIdentifierName(); while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(136 /* QualifiedName */, elementName.pos); + var node = createNode(137 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); @@ -10213,7 +10436,7 @@ var ts; return elementName; } function parseJsxExpression(inExpressionContext) { - var node = createNode(243 /* JsxExpression */); + var node = createNode(244 /* JsxExpression */); parseExpected(15 /* OpenBraceToken */); if (token !== 16 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); @@ -10232,7 +10455,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(241 /* JsxAttribute */); + var node = createNode(242 /* JsxAttribute */); node.name = parseIdentifierName(); if (parseOptional(56 /* EqualsToken */)) { switch (token) { @@ -10247,7 +10470,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(242 /* JsxSpreadAttribute */); + var node = createNode(243 /* JsxSpreadAttribute */); parseExpected(15 /* OpenBraceToken */); parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); @@ -10255,7 +10478,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(240 /* JsxClosingElement */); + var node = createNode(241 /* JsxClosingElement */); parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -10268,7 +10491,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(174 /* TypeAssertionExpression */); + var node = createNode(175 /* TypeAssertionExpression */); parseExpected(25 /* LessThanToken */); node.type = parseType(); parseExpected(27 /* GreaterThanToken */); @@ -10279,7 +10502,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(169 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(170 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -10288,7 +10511,7 @@ var ts; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(170 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(171 /* 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. @@ -10304,7 +10527,7 @@ var ts; continue; } if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { - var tagExpression = createNode(173 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(174 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -10327,7 +10550,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(171 /* CallExpression */, expression.pos); + var callExpr = createNode(172 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -10335,7 +10558,7 @@ var ts; continue; } else if (token === 17 /* OpenParenToken */) { - var callExpr = createNode(171 /* CallExpression */, expression.pos); + var callExpr = createNode(172 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10359,7 +10582,7 @@ var ts; // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } - // If we have a '<', then only parse this as a arugment list if the type arguments + // If we have a '<', then only parse this as a argument list if the type arguments // are complete and we have an open paren. if we don't, rewind and return nothing. return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments @@ -10445,41 +10668,42 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(175 /* ParenthesizedExpression */); + var node = createNode(176 /* ParenthesizedExpression */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(188 /* SpreadElementExpression */); + var node = createNode(189 /* SpreadElementExpression */); parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token === 24 /* CommaToken */ ? createNode(190 /* OmittedExpression */) : + token === 24 /* CommaToken */ ? createNode(191 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(167 /* ArrayLiteralExpression */); + var node = createNode(168 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); - if (scanner.hasPrecedingLineBreak()) - node.flags |= 1024 /* MultiLine */; + if (scanner.hasPrecedingLineBreak()) { + node.multiLine = true; + } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(146 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(147 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(129 /* SetKeyword */)) { - return parseAccessorDeclaration(147 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(130 /* SetKeyword */)) { + return parseAccessorDeclaration(148 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10506,7 +10730,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */ || token === 56 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(249 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(250 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(56 /* EqualsToken */); @@ -10514,25 +10738,25 @@ var ts; shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } - return finishNode(shorthandDeclaration); + return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(248 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(249 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; parseExpected(54 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); + return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(168 /* ObjectLiteralExpression */); + var node = createNode(169 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 1024 /* MultiLine */; + node.multiLine = true; } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } @@ -10546,7 +10770,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(176 /* FunctionExpression */); + var node = createNode(177 /* FunctionExpression */); setModifiers(node, parseModifiers()); parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); @@ -10562,13 +10786,13 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseOptionalIdentifier() { return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(172 /* NewExpression */); + var node = createNode(173 /* NewExpression */); parseExpected(92 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -10579,7 +10803,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(195 /* Block */); + var node = createNode(196 /* Block */); if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -10609,12 +10833,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(197 /* EmptyStatement */); + var node = createNode(198 /* EmptyStatement */); parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(199 /* IfStatement */); + var node = createNode(200 /* IfStatement */); parseExpected(88 /* IfKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10624,7 +10848,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(200 /* DoStatement */); + var node = createNode(201 /* DoStatement */); parseExpected(79 /* DoKeyword */); node.statement = parseStatement(); parseExpected(104 /* WhileKeyword */); @@ -10639,7 +10863,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(201 /* WhileStatement */); + var node = createNode(202 /* WhileStatement */); parseExpected(104 /* WhileKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10662,21 +10886,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(203 /* ForInStatement */, pos); + var forInStatement = createNode(204 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(135 /* OfKeyword */)) { - var forOfStatement = createNode(204 /* ForOfStatement */, pos); + else if (parseOptional(136 /* OfKeyword */)) { + var forOfStatement = createNode(205 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(202 /* ForStatement */, pos); + var forStatement = createNode(203 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(23 /* SemicolonToken */); if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { @@ -10694,7 +10918,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 206 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + parseExpected(kind === 207 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10702,7 +10926,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(207 /* ReturnStatement */); + var node = createNode(208 /* ReturnStatement */); parseExpected(94 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -10711,7 +10935,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(208 /* WithStatement */); + var node = createNode(209 /* WithStatement */); parseExpected(105 /* WithKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -10720,7 +10944,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(244 /* CaseClause */); + var node = createNode(245 /* CaseClause */); parseExpected(71 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(54 /* ColonToken */); @@ -10728,7 +10952,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(245 /* DefaultClause */); + var node = createNode(246 /* DefaultClause */); parseExpected(77 /* DefaultKeyword */); parseExpected(54 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -10738,12 +10962,12 @@ var ts; return token === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(209 /* SwitchStatement */); + var node = createNode(210 /* SwitchStatement */); parseExpected(96 /* SwitchKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(223 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(224 /* CaseBlock */, scanner.getStartPos()); parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(16 /* CloseBraceToken */); @@ -10758,7 +10982,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(211 /* ThrowStatement */); + var node = createNode(212 /* ThrowStatement */); parseExpected(98 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -10766,7 +10990,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(212 /* TryStatement */); + var node = createNode(213 /* TryStatement */); parseExpected(100 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -10779,7 +11003,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(247 /* CatchClause */); + var result = createNode(248 /* CatchClause */); parseExpected(72 /* CatchKeyword */); if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -10789,7 +11013,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(213 /* DebuggerStatement */); + var node = createNode(214 /* DebuggerStatement */); parseExpected(76 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -10801,16 +11025,16 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(210 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(211 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); + return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(198 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(199 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); - return finishNode(expressionStatement); + return addJSDocComment(finishNode(expressionStatement)); } } function nextTokenIsIdentifierOrKeywordOnSameLine() { @@ -10857,7 +11081,7 @@ var ts; // // could be legal, it would add complexity for very little gain. case 107 /* InterfaceKeyword */: - case 132 /* TypeKeyword */: + case 133 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: @@ -10868,13 +11092,14 @@ var ts; case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: case 112 /* PublicKeyword */: + case 127 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 134 /* GlobalKeyword */: + case 135 /* GlobalKeyword */: return nextToken() === 15 /* OpenBraceToken */; case 89 /* ImportKeyword */: nextToken(); @@ -10934,14 +11159,15 @@ var ts; case 107 /* InterfaceKeyword */: case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: - case 132 /* TypeKeyword */: - case 134 /* GlobalKeyword */: + case 133 /* TypeKeyword */: + case 135 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: case 113 /* StaticKeyword */: + case 127 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10984,9 +11210,9 @@ var ts; case 86 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(205 /* ContinueStatement */); + return parseBreakOrContinueStatement(206 /* ContinueStatement */); case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(206 /* BreakStatement */); + return parseBreakOrContinueStatement(207 /* BreakStatement */); case 94 /* ReturnKeyword */: return parseReturnStatement(); case 105 /* WithKeyword */: @@ -11006,7 +11232,7 @@ var ts; return parseDeclaration(); case 118 /* AsyncKeyword */: case 107 /* InterfaceKeyword */: - case 132 /* TypeKeyword */: + case 133 /* TypeKeyword */: case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: case 122 /* DeclareKeyword */: @@ -11019,7 +11245,8 @@ var ts; case 112 /* PublicKeyword */: case 115 /* AbstractKeyword */: case 113 /* StaticKeyword */: - case 134 /* GlobalKeyword */: + case 127 /* ReadonlyKeyword */: + case 135 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -11042,11 +11269,11 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 107 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 132 /* TypeKeyword */: + case 133 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 81 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 134 /* GlobalKeyword */: + case 135 /* GlobalKeyword */: case 125 /* ModuleKeyword */: case 126 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); @@ -11061,7 +11288,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(234 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(235 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -11083,16 +11310,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token === 24 /* CommaToken */) { - return createNode(190 /* OmittedExpression */); + return createNode(191 /* OmittedExpression */); } - var node = createNode(166 /* BindingElement */); + var node = createNode(167 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(166 /* BindingElement */); + var node = createNode(167 /* BindingElement */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token !== 54 /* ColonToken */) { @@ -11107,14 +11334,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(164 /* ObjectBindingPattern */); + var node = createNode(165 /* ObjectBindingPattern */); parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(165 /* ArrayBindingPattern */); + var node = createNode(166 /* ArrayBindingPattern */); parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(20 /* CloseBracketToken */); @@ -11133,7 +11360,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(214 /* VariableDeclaration */); + var node = createNode(215 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -11142,15 +11369,15 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(215 /* VariableDeclarationList */); + var node = createNode(216 /* VariableDeclarationList */); switch (token) { case 102 /* VarKeyword */: break; case 108 /* LetKeyword */: - node.flags |= 8192 /* Let */; + node.flags |= 1024 /* Let */; break; case 74 /* ConstKeyword */: - node.flags |= 16384 /* Const */; + node.flags |= 2048 /* Const */; break; default: ts.Debug.fail(); @@ -11165,7 +11392,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 === 135 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 136 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -11180,15 +11407,15 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(196 /* VariableStatement */, fullStart); + var node = createNode(197 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(216 /* FunctionDeclaration */, fullStart); + var node = createNode(217 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(87 /* FunctionKeyword */); @@ -11198,19 +11425,19 @@ var ts; var isAsync = !!(node.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(145 /* Constructor */, pos); + var node = createNode(146 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(121 /* ConstructorKeyword */); fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(144 /* MethodDeclaration */, fullStart); + var method = createNode(145 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -11220,10 +11447,10 @@ var ts; var isAsync = !!(method.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); + return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(142 /* PropertyDeclaration */, fullStart); + var property = createNode(143 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11234,13 +11461,13 @@ var ts; // off. The grammar would look something like this: // // MemberVariableDeclaration[Yield]: - // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In]; - // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; + // AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initializer_opt[In]; + // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initializer_opt[In, ?Yield]; // // The checker may still error in the static case to explicitly disallow the yield expression. - property.initializer = modifiers && modifiers.flags & 64 /* Static */ + property.initializer = modifiers && modifiers.flags & 32 /* Static */ ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); + : doOutsideOfContext(8388608 /* YieldContext */ | 4194304 /* DisallowInContext */, parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } @@ -11275,6 +11502,7 @@ var ts; case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: case 113 /* StaticKeyword */: + case 127 /* ReadonlyKeyword */: return true; default: return false; @@ -11315,7 +11543,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 129 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 130 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -11349,7 +11577,7 @@ var ts; decorators = []; decorators.pos = decoratorStart; } - var decorator = createNode(140 /* Decorator */, decoratorStart); + var decorator = createNode(141 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11414,7 +11642,7 @@ var ts; } function parseClassElement() { if (token === 23 /* SemicolonToken */) { - var result = createNode(194 /* SemicolonClassElement */); + var result = createNode(195 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11452,10 +11680,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 189 /* ClassExpression */); + /*modifiers*/ undefined, 190 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 217 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 218 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -11499,7 +11727,7 @@ var ts; } function parseHeritageClause() { if (token === 83 /* ExtendsKeyword */ || token === 106 /* ImplementsKeyword */) { - var node = createNode(246 /* HeritageClause */); + var node = createNode(247 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11508,7 +11736,7 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(191 /* ExpressionWithTypeArguments */); + var node = createNode(192 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 25 /* LessThanToken */) { node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); @@ -11522,7 +11750,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218 /* InterfaceDeclaration */, fullStart); + var node = createNode(219 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(107 /* InterfaceKeyword */); @@ -11533,10 +11761,10 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(219 /* TypeAliasDeclaration */, fullStart); + var node = createNode(220 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(132 /* TypeKeyword */); + parseExpected(133 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(56 /* EqualsToken */); @@ -11549,13 +11777,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(250 /* EnumMember */, scanner.getStartPos()); + var node = createNode(251 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220 /* EnumDeclaration */, fullStart); + var node = createNode(221 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); parseExpected(81 /* EnumKeyword */); @@ -11570,7 +11798,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(222 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(223 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(16 /* CloseBraceToken */); @@ -11581,27 +11809,27 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(221 /* ModuleDeclaration */, fullStart); + var node = createNode(222 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 65536 /* Namespace */; + var namespaceFlag = flags & 4096 /* Namespace */; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 2 /* Export */ | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221 /* ModuleDeclaration */, fullStart); + var node = createNode(222 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (token === 134 /* GlobalKeyword */) { + if (token === 135 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 2097152 /* GlobalAugmentation */; + node.flags |= 131072 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(/*internName*/ true); @@ -11611,12 +11839,12 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (token === 134 /* GlobalKeyword */) { + if (token === 135 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } else if (parseOptional(126 /* NamespaceKeyword */)) { - flags |= 65536 /* Namespace */; + flags |= 4096 /* Namespace */; } else { parseExpected(125 /* ModuleKeyword */); @@ -11627,7 +11855,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 127 /* RequireKeyword */ && + return token === 128 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -11642,11 +11870,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 24 /* CommaToken */ && token !== 133 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 134 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(224 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(225 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; @@ -11657,7 +11885,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(225 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(226 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: @@ -11667,7 +11895,7 @@ var ts; token === 37 /* AsteriskToken */ || token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(133 /* FromKeyword */); + parseExpected(134 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11680,7 +11908,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(226 /* ImportClause */, fullStart); + var importClause = createNode(227 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11690,7 +11918,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(228 /* NamedImports */); + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(229 /* NamedImports */); } return finishNode(importClause); } @@ -11700,8 +11928,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(235 /* ExternalModuleReference */); - parseExpected(127 /* RequireKeyword */); + var node = createNode(236 /* ExternalModuleReference */); + parseExpected(128 /* RequireKeyword */); parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(18 /* CloseParenToken */); @@ -11723,7 +11951,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(227 /* NamespaceImport */); + var namespaceImport = createNode(228 /* NamespaceImport */); parseExpected(37 /* AsteriskToken */); parseExpected(116 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -11738,21 +11966,21 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 228 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 229 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(233 /* ExportSpecifier */); + return parseImportOrExportSpecifier(234 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(229 /* ImportSpecifier */); + return parseImportOrExportSpecifier(230 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); // ImportSpecifier: // BindingIdentifier // IdentifierName as BindingIdentifier - // ExportSpecififer: + // ExportSpecifier: // IdentifierName // IdentifierName as IdentifierName var checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); @@ -11770,27 +11998,27 @@ var ts; else { node.name = identifierName; } - if (kind === 229 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 230 /* 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(231 /* ExportDeclaration */, fullStart); + var node = createNode(232 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(133 /* FromKeyword */); + parseExpected(134 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(232 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(233 /* 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 === 133 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(133 /* FromKeyword */); + if (token === 134 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(134 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11798,7 +12026,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(230 /* ExportAssignment */, fullStart); + var node = createNode(231 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); if (parseOptional(56 /* EqualsToken */)) { @@ -11872,11 +12100,11 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 2 /* Export */ - || node.kind === 224 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 235 /* ExternalModuleReference */ - || node.kind === 225 /* ImportDeclaration */ - || node.kind === 230 /* ExportAssignment */ - || node.kind === 231 /* ExportDeclaration */ + return node.flags & 1 /* Export */ + || node.kind === 225 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 236 /* ExternalModuleReference */ + || node.kind === 226 /* ImportDeclaration */ + || node.kind === 231 /* ExportAssignment */ + || node.kind === 232 /* ExportDeclaration */ ? node : undefined; }); @@ -11937,21 +12165,19 @@ var ts; } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); - var jsDocTypeExpression = parseJSDocTypeExpression(start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + scanner.setText(content, start, length); + token = scanner.scan(); + var jsDocTypeExpression = parseJSDocTypeExpression(); var diagnostics = parseDiagnostics; clearState(); return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - // Parses out a JSDoc type expression. The starting position should be right at the open - // curly in the type expression. Returns 'undefined' if it encounters any errors while parsing. + // Parses out a JSDoc type expression. /* @internal */ - function parseJSDocTypeExpression(start, length) { - scanner.setText(sourceText, start, length); - // Prime the first token for us to start processing. - token = nextToken(); - var result = createNode(252 /* JSDocTypeExpression */); + function parseJSDocTypeExpression() { + var result = createNode(253 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(16 /* CloseBraceToken */); @@ -11962,12 +12188,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token === 47 /* BarToken */) { - var unionType = createNode(256 /* JSDocUnionType */, type.pos); + var unionType = createNode(257 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token === 56 /* EqualsToken */) { - var optionalType = createNode(263 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(264 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11978,20 +12204,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 19 /* OpenBracketToken */) { - var arrayType = createNode(255 /* JSDocArrayType */, type.pos); + var arrayType = createNode(256 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token === 53 /* QuestionToken */) { - var nullableType = createNode(258 /* JSDocNullableType */, type.pos); + var nullableType = createNode(259 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token === 49 /* ExclamationToken */) { - var nonNullableType = createNode(259 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(260 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -12025,10 +12251,10 @@ var ts; case 97 /* ThisKeyword */: return parseJSDocThisType(); case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: case 103 /* VoidKeyword */: return parseTokenNode(); } @@ -12036,27 +12262,27 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(267 /* JSDocThisType */); + var result = createNode(268 /* JSDocThisType */); nextToken(); parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(266 /* JSDocConstructorType */); + var result = createNode(267 /* JSDocConstructorType */); nextToken(); parseExpected(54 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(265 /* JSDocVariadicType */); + var result = createNode(266 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(264 /* JSDocFunctionType */); + var result = createNode(265 /* JSDocFunctionType */); nextToken(); parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); @@ -12069,20 +12295,28 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(139 /* Parameter */); + var parameter = createNode(140 /* Parameter */); parameter.type = parseJSDocType(); + if (parseOptional(56 /* EqualsToken */)) { + parameter.questionToken = createNode(56 /* EqualsToken */); + } return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(262 /* JSDocTypeReference */); + var result = createNode(263 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - while (parseOptional(21 /* DotToken */)) { - if (token === 25 /* LessThanToken */) { - result.typeArguments = parseTypeArguments(); - break; - } - else { - result.name = parseQualifiedName(result.name); + if (token === 25 /* LessThanToken */) { + result.typeArguments = parseTypeArguments(); + } + else { + while (parseOptional(21 /* DotToken */)) { + if (token === 25 /* LessThanToken */) { + result.typeArguments = parseTypeArguments(); + break; + } + else { + result.name = parseQualifiedName(result.name); + } } } return finishNode(result); @@ -12104,13 +12338,13 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(136 /* QualifiedName */, left.pos); + var result = createNode(137 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(260 /* JSDocRecordType */); + var result = createNode(261 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); @@ -12118,7 +12352,7 @@ var ts; return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(261 /* JSDocRecordMember */); + var result = createNode(262 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); if (token === 54 /* ColonToken */) { nextToken(); @@ -12127,13 +12361,13 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(259 /* JSDocNonNullableType */); + var result = createNode(260 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(257 /* JSDocTupleType */); + var result = createNode(258 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); @@ -12147,7 +12381,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(256 /* JSDocUnionType */); + var result = createNode(257 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(18 /* CloseParenToken */); @@ -12165,7 +12399,7 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(253 /* JSDocAllType */); + var result = createNode(254 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -12188,29 +12422,35 @@ var ts; token === 27 /* GreaterThanToken */ || token === 56 /* EqualsToken */ || token === 47 /* BarToken */) { - var result = createNode(254 /* JSDocUnknownType */, pos); + var result = createNode(255 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(258 /* JSDocNullableType */, pos); + var result = createNode(259 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*isJavaScriptFile*/ true, /*_syntaxCursor:*/ undefined); - var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDocComment = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; } JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment; function parseJSDocComment(parent, start, length) { + var saveToken = token; + var saveParseDiagnosticsLength = parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; var comment = parseJSDocCommentWorker(start, length); if (comment) { - fixupParentReferences(comment); comment.parent = parent; } + token = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; @@ -12223,77 +12463,75 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; - var pos; - // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I - // considered using an actual Scanner, but this would complicate things. The - // scanner would need to know it was in a Doc Comment. Otherwise, it would then - // produce comments *inside* the doc comment. In the end it was just easier to - // write a simple scanner rather than go that route. - if (length >= "/** */".length) { - if (content.charCodeAt(start) === 47 /* slash */ && - content.charCodeAt(start + 1) === 42 /* asterisk */ && - content.charCodeAt(start + 2) === 42 /* asterisk */ && - content.charCodeAt(start + 3) !== 42 /* asterisk */) { + var result; + // Check for /** (JSDoc opening part) + if (content.charCodeAt(start) === 47 /* slash */ && + content.charCodeAt(start + 1) === 42 /* asterisk */ && + content.charCodeAt(start + 2) === 42 /* asterisk */ && + content.charCodeAt(start + 3) !== 42 /* asterisk */) { + // + 3 for leading /**, - 5 in total for /** */ + scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var canParseTag = true; var seenAsterisk = true; - for (pos = start + "/**".length; pos < end;) { - var ch = content.charCodeAt(pos); - pos++; - if (ch === 64 /* at */ && canParseTag) { - parseTag(); - // Once we parse out a tag, we cannot keep parsing out tags on this line. - canParseTag = false; - continue; - } - if (ts.isLineBreak(ch)) { - // After a line break, we can parse a tag, and we haven't seen as asterisk - // on the next line yet. - canParseTag = true; - seenAsterisk = false; - continue; - } - if (ts.isWhiteSpace(ch)) { - // Whitespace doesn't affect any of our parsing. - continue; - } - // Ignore the first asterisk on a line. - if (ch === 42 /* asterisk */) { - if (seenAsterisk) { - // If we've already seen an asterisk, then we can no longer parse a tag - // on this line. + nextJSDocToken(); + while (token !== 1 /* EndOfFileToken */) { + switch (token) { + case 55 /* AtToken */: + if (canParseTag) { + parseTag(); + } + // This will take us to the end of the line, so it's OK to parse a tag on the next pass through the loop + seenAsterisk = false; + break; + case 4 /* NewLineTrivia */: + // After a line break, we can parse a tag, and we haven't seen an asterisk on the next line yet + canParseTag = true; + seenAsterisk = false; + break; + case 37 /* AsteriskToken */: + if (seenAsterisk) { + // If we've already seen an asterisk, then we can no longer parse a tag on this line + canParseTag = false; + } + // Ignore the first asterisk on a line + seenAsterisk = true; + break; + case 69 /* Identifier */: + // Anything else is doc comment text. We can't do anything with it. Because it + // wasn't a tag, we can no longer parse a tag on this line until we hit the next + // line break. canParseTag = false; - } - seenAsterisk = true; - continue; + break; + case 1 /* EndOfFileToken */: + break; } - // Anything else is doc comment text. We can't do anything with it. Because it - // wasn't a tag, we can no longer parse a tag on this line until we hit the next - // line break. - canParseTag = false; + nextJSDocToken(); } - } + result = createJSDocComment(); + }); } - return createJSDocComment(); + return result; function createJSDocComment() { if (!tags) { return undefined; } - var result = createNode(268 /* JSDocComment */, start); + var result = createNode(269 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } function skipWhitespace() { - while (pos < end && ts.isWhiteSpace(content.charCodeAt(pos))) { - pos++; + while (token === 5 /* WhitespaceTrivia */ || token === 4 /* NewLineTrivia */) { + nextJSDocToken(); } } function parseTag() { - ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(55 /* AtToken */, pos - 1); - atToken.end = pos; - var tagName = scanIdentifier(); + ts.Debug.assert(token === 55 /* AtToken */); + var atToken = createNode(55 /* AtToken */, scanner.getTokenPos()); + atToken.end = scanner.getTextPos(); + nextJSDocToken(); + var tagName = parseJSDocIdentifier(); if (!tagName) { return; } @@ -12317,10 +12555,10 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(269 /* JSDocTag */, atToken.pos); + var result = createNode(270 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; - return finishNode(result, pos); + return finishNode(result); } function addTag(tag) { if (tag) { @@ -12333,12 +12571,10 @@ var ts; } } function tryParseTypeExpression() { - skipWhitespace(); - if (content.charCodeAt(pos) !== 123 /* openBrace */) { + if (token !== 15 /* OpenBraceToken */) { return undefined; } - var typeExpression = parseJSDocTypeExpression(pos, end - pos); - pos = typeExpression.end; + var typeExpression = parseJSDocTypeExpression(); return typeExpression; } function handleParamTag(atToken, tagName) { @@ -12346,17 +12582,22 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (content.charCodeAt(pos) === 91 /* openBracket */) { - pos++; - skipWhitespace(); - name = scanIdentifier(); + // Looking for something like '[foo]' or 'foo' + if (parseOptionalToken(19 /* OpenBracketToken */)) { + name = parseJSDocIdentifier(); isBracketed = true; + // May have an optional default, e.g. '[foo = 42]' + if (parseOptionalToken(56 /* EqualsToken */)) { + parseExpression(); + } + parseExpected(20 /* CloseBracketToken */); } - else { - name = scanIdentifier(); + else if (token === 69 /* Identifier */) { + name = parseJSDocIdentifier(); } if (!name) { - parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); + parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + return undefined; } var preName, postName; if (typeExpression) { @@ -12368,84 +12609,82 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(270 /* JSDocParameterTag */, atToken.pos); + var result = createNode(271 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; result.typeExpression = typeExpression; result.postParameterName = postName; result.isBracketed = isBracketed; - return finishNode(result, pos); + return finishNode(result); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 271 /* JSDocReturnTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + if (ts.forEach(tags, function (t) { return t.kind === 272 /* JSDocReturnTag */; })) { + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(271 /* JSDocReturnTag */, atToken.pos); + var result = createNode(272 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); + return finishNode(result); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 272 /* JSDocTypeTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + if (ts.forEach(tags, function (t) { return t.kind === 273 /* JSDocTypeTag */; })) { + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(272 /* JSDocTypeTag */, atToken.pos); + var result = createNode(273 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); + return finishNode(result); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 273 /* JSDocTemplateTag */; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + if (ts.forEach(tags, function (t) { return t.kind === 274 /* JSDocTemplateTag */; })) { + parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + // Type parameter list looks like '@template T,U,V' var typeParameters = []; - typeParameters.pos = pos; + typeParameters.pos = scanner.getStartPos(); while (true) { - skipWhitespace(); - var startPos = pos; - var name_8 = scanIdentifier(); + var name_8 = parseJSDocIdentifier(); if (!name_8) { - parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); + parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(138 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(139 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; - finishNode(typeParameter, pos); + finishNode(typeParameter); typeParameters.push(typeParameter); - skipWhitespace(); - if (content.charCodeAt(pos) !== 44 /* comma */) { + if (token === 24 /* CommaToken */) { + nextJSDocToken(); + } + else { break; } - pos++; } - typeParameters.end = pos; - var result = createNode(273 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(274 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; - return finishNode(result, pos); + finishNode(result); + typeParameters.end = result.end; + return result; } - function scanIdentifier() { - var startPos = pos; - for (; pos < end; pos++) { - var ch = content.charCodeAt(pos); - if (pos === startPos && ts.isIdentifierStart(ch, 2 /* Latest */)) { - continue; - } - else if (pos > startPos && ts.isIdentifierPart(ch, 2 /* Latest */)) { - continue; - } - break; - } - if (startPos === pos) { + function nextJSDocToken() { + return token = scanner.scanJSDocToken(); + } + function parseJSDocIdentifier() { + if (token !== 69 /* Identifier */) { + parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(69 /* Identifier */, startPos); - result.text = content.substring(startPos, pos); - return finishNode(result, pos); + var pos = scanner.getTokenPos(); + var end = scanner.getTextPos(); + var result = createNode(69 /* Identifier */, pos); + result.text = content.substring(pos, end); + finishNode(result, end); + nextJSDocToken(); + return result; } } JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; @@ -12463,10 +12702,10 @@ 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, /*syntaxCursor*/ undefined, /*setParentNodes*/ true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind); } // 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. + // we do an update the original source file is considered unusable from that point onwards. // // This is because we do incremental parsing in-place. i.e. we take nodes from the old // tree and give them new positions and parents. From that point on, trusting the old @@ -12519,7 +12758,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, /*setParentNodes*/ true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -12578,7 +12817,7 @@ var ts; // We have an element that intersects the change range in some way. It may have its // start, or its end (or both) in the changed range. We want to adjust any part // that intersects such that the final tree is in a consistent state. i.e. all - // chlidren have spans within the span of their parent, and all siblings are ordered + // children have spans within the span of their parent, and all siblings are ordered // properly. // We may need to update both the 'pos' and the 'end' of the element. // If the 'pos' is before the start of the change, then we don't need to touch it. @@ -12598,7 +12837,7 @@ var ts; // -------------------ZZZ----------------- // // In this case, any element that started in the 'X' range will keep its position. - // However any element htat started after that will have their pos adjusted to be + // However any element that started after that will have their pos adjusted to be // at the end of the new range. i.e. any node that started in the 'Y' range will // be adjusted to have their start at the end of the 'Z' range. // @@ -12622,7 +12861,7 @@ var ts; // -------------------ZZZ----------------- // // In this case, any element that ended in the 'X' range will keep its position. - // However any element htat ended after that will have their pos adjusted to be + // However any element that ended after that will have their pos adjusted to be // at the end of the new range. i.e. any node that ended in the 'Y' range will // be adjusted to have their end at the end of the 'Z' range. if (element.end >= changeRangeOldEnd) { @@ -12642,12 +12881,12 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos = node.pos; + var pos_2 = node.pos; forEachChild(node, function (child) { - ts.Debug.assert(child.pos >= pos); - pos = child.end; + ts.Debug.assert(child.pos >= pos_2); + pos_2 = child.end; }); - ts.Debug.assert(pos <= node.end); + ts.Debug.assert(pos_2 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -12881,7 +13120,7 @@ var ts; if (position >= node.pos && position < node.end) { // Position was within this node. Keep searching deeper to find the node. forEachChild(node, visitNode, visitArray); - // don't procede any futher in the search. + // don't proceed any further in the search. return true; } // position wasn't in this node, have to keep searching. @@ -12937,7 +13176,7 @@ var ts; var ModuleInstanceState = ts.ModuleInstanceState; var Reachability; (function (Reachability) { - Reachability[Reachability["Unintialized"] = 1] = "Unintialized"; + Reachability[Reachability["Uninitialized"] = 1] = "Uninitialized"; Reachability[Reachability["Reachable"] = 2] = "Reachable"; Reachability[Reachability["Unreachable"] = 4] = "Unreachable"; Reachability[Reachability["ReportedUnreachable"] = 8] = "ReportedUnreachable"; @@ -12952,17 +13191,17 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 218 /* InterfaceDeclaration */ || node.kind === 219 /* TypeAliasDeclaration */) { + if (node.kind === 219 /* InterfaceDeclaration */ || node.kind === 220 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 225 /* ImportDeclaration */ || node.kind === 224 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { + else if ((node.kind === 226 /* ImportDeclaration */ || node.kind === 225 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 222 /* ModuleBlock */) { - var state = 0 /* NonInstantiated */; + else if (node.kind === 223 /* ModuleBlock */) { + var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { case 0 /* NonInstantiated */: @@ -12970,17 +13209,17 @@ var ts; return false; case 2 /* ConstEnumOnly */: // child is const enum only - record state and continue searching - state = 2 /* ConstEnumOnly */; + state_1 = 2 /* ConstEnumOnly */; return false; case 1 /* Instantiated */: // child is instantiated - record state and stop - state = 1 /* Instantiated */; + state_1 = 1 /* Instantiated */; return true; } }); - return state; + return state_1; } - else if (node.kind === 221 /* ModuleDeclaration */) { + else if (node.kind === 222 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -13090,7 +13329,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 221 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 222 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -13103,7 +13342,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -13115,21 +13354,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 145 /* Constructor */: + case 146 /* Constructor */: return "__constructor"; - case 153 /* FunctionType */: - case 148 /* CallSignature */: + case 154 /* FunctionType */: + case 149 /* CallSignature */: return "__call"; - case 154 /* ConstructorType */: - case 149 /* ConstructSignature */: + case 155 /* ConstructorType */: + case 150 /* ConstructSignature */: return "__new"; - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: return "__index"; - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return "__export"; - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -13144,9 +13383,18 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 216 /* FunctionDeclaration */: - case 217 /* ClassDeclaration */: + case 217 /* FunctionDeclaration */: + case 218 /* ClassDeclaration */: return node.flags & 512 /* Default */ ? "default" : undefined; + case 265 /* JSDocFunctionType */: + return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; + case 140 /* Parameter */: + // Parameters with names are handled at the top of this function. Parameters + // without names can only come from JSDocFunctionTypes. + ts.Debug.assert(node.parent.kind === 265 /* JSDocFunctionType */); + var functionType = node.parent; + var index = ts.indexOf(functionType.parameters, node); + return "p" + index; } } function getDisplayName(node) { @@ -13197,18 +13445,18 @@ var ts; } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { if (declaration.flags & 512 /* Default */) { - message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); ts.forEach(symbol.declarations, function (declaration) { - file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message_1, getDisplayName(declaration))); }); - file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + file.bindDiagnostics.push(ts.createDiagnosticForNode(node.name || node, message_1, getDisplayName(node))); symbol = createSymbol(0 /* None */, name); } } @@ -13220,9 +13468,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 2 /* Export */; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 233 /* ExportSpecifier */ || (node.kind === 224 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 234 /* ExportSpecifier */ || (node.kind === 225 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -13245,7 +13493,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 131072 /* ExportContext */)) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 8192 /* ExportContext */)) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -13263,7 +13511,7 @@ var ts; // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. function bindChildren(node) { - // Before we recurse into a node's chilren, we first save the existing parent, container + // Before we recurse into a node's children, we first save the existing parent, container // and block-container. Then after we pop out of processing the children, we restore // these saved values. var saveParent = parent; @@ -13286,7 +13534,7 @@ var ts; // Finally, if this is a block-container, then we clear out any existing .locals object // it may contain within it. This happens in incremental scenarios. Because we can be // reusing a node from a previous compilation, that node may have had 'locals' created - // for it. We must clear this so we don't accidently move any stale data forward from + // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. var containerFlags = getContainerFlags(node); if (containerFlags & 1 /* IsContainer */) { @@ -13308,13 +13556,13 @@ var ts; var kind = node.kind; var flags = node.flags; // reset all reachability check related flags on node (for incremental scenarios) - flags &= ~1572864 /* ReachabilityCheckFlags */; + flags &= ~98304 /* ReachabilityCheckFlags */; // reset all emit helper flags on node (for incremental scenarios) - flags &= ~62914560 /* EmitHelperFlags */; - if (kind === 218 /* InterfaceDeclaration */) { + flags &= ~3932160 /* EmitHelperFlags */; + if (kind === 219 /* InterfaceDeclaration */) { seenThisKeyword = false; } - var saveState = kind === 251 /* SourceFile */ || kind === 222 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); + var saveState = kind === 252 /* SourceFile */ || kind === 223 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); if (saveState) { savedReachabilityState = currentReachabilityState; savedLabelStack = labelStack; @@ -13325,28 +13573,31 @@ var ts; hasExplicitReturn = false; labelStack = labelIndexMap = implicitLabels = undefined; } + if (ts.isInJavaScriptFile(node) && node.jsDocComment) { + bind(node.jsDocComment); + } bindReachableStatement(node); if (currentReachabilityState === 2 /* Reachable */ && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { - flags |= 524288 /* HasImplicitReturn */; + flags |= 32768 /* HasImplicitReturn */; if (hasExplicitReturn) { - flags |= 1048576 /* HasExplicitReturn */; + flags |= 65536 /* HasExplicitReturn */; } } - if (kind === 218 /* InterfaceDeclaration */) { - flags = seenThisKeyword ? flags | 262144 /* ContainsThis */ : flags & ~262144 /* ContainsThis */; + if (kind === 219 /* InterfaceDeclaration */) { + flags = seenThisKeyword ? flags | 16384 /* ContainsThis */ : flags & ~16384 /* ContainsThis */; } - if (kind === 251 /* SourceFile */) { + if (kind === 252 /* SourceFile */) { if (hasClassExtends) { - flags |= 4194304 /* HasClassExtends */; + flags |= 262144 /* HasClassExtends */; } if (hasDecorators) { - flags |= 8388608 /* HasDecorators */; + flags |= 524288 /* HasDecorators */; } if (hasParameterDecorators) { - flags |= 16777216 /* HasParamDecorators */; + flags |= 1048576 /* HasParamDecorators */; } if (hasAsyncFunctions) { - flags |= 33554432 /* HasAsyncFunctions */; + flags |= 2097152 /* HasAsyncFunctions */; } } node.flags = flags; @@ -13371,40 +13622,40 @@ var ts; return; } switch (node.kind) { - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: bindWhileStatement(node); break; - case 200 /* DoStatement */: + case 201 /* DoStatement */: bindDoStatement(node); break; - case 202 /* ForStatement */: + case 203 /* ForStatement */: bindForStatement(node); break; - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 199 /* IfStatement */: + case 200 /* IfStatement */: bindIfStatement(node); break; - case 207 /* ReturnStatement */: - case 211 /* ThrowStatement */: + case 208 /* ReturnStatement */: + case 212 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 206 /* BreakStatement */: - case 205 /* ContinueStatement */: + case 207 /* BreakStatement */: + case 206 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 212 /* TryStatement */: + case 213 /* TryStatement */: bindTryStatement(node); break; - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: bindSwitchStatement(node); break; - case 223 /* CaseBlock */: + case 224 /* CaseBlock */: bindCaseBlock(node); break; - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: bindLabeledStatement(node); break; default: @@ -13479,7 +13730,7 @@ var ts; function bindReturnOrThrow(n) { // bind expression (don't affect reachability) bind(n.expression); - if (n.kind === 207 /* ReturnStatement */) { + if (n.kind === 208 /* ReturnStatement */) { hasExplicitReturn = true; } currentReachabilityState = 4 /* Unreachable */; @@ -13488,7 +13739,7 @@ var ts; // call bind on label (don't affect reachability) bind(n.label); // for continue case touch label so it will be marked a used - var isValidJump = jumpToLabel(n.label, n.kind === 206 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); + var isValidJump = jumpToLabel(n.label, n.kind === 207 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); if (isValidJump) { currentReachabilityState = 4 /* Unreachable */; } @@ -13514,8 +13765,8 @@ var ts; // bind expression (don't affect reachability) bind(n.expression); bind(n.caseBlock); - var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 245 /* DefaultClause */; }); - // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 246 /* DefaultClause */; }); + // post switch state is unreachable if switch is exhaustive (has a default case ) and does not have fallthrough from the last case var postSwitchState = hasDefault && currentReachabilityState !== 2 /* Reachable */ ? 4 /* Unreachable */ : preSwitchState; popImplicitLabel(postSwitchLabel, postSwitchState); } @@ -13541,39 +13792,40 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 189 /* ClassExpression */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 156 /* TypeLiteral */: - case 168 /* ObjectLiteralExpression */: + case 190 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 169 /* ObjectLiteralExpression */: + case 157 /* TypeLiteral */: + case 261 /* JSDocRecordType */: return 1 /* IsContainer */; - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 216 /* FunctionDeclaration */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 221 /* ModuleDeclaration */: - case 251 /* SourceFile */: - case 219 /* TypeAliasDeclaration */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 217 /* FunctionDeclaration */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 222 /* ModuleDeclaration */: + case 252 /* SourceFile */: + case 220 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 247 /* CatchClause */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 223 /* CaseBlock */: + case 248 /* CatchClause */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 224 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 195 /* Block */: + case 196 /* 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' + // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following // example: // @@ -13608,38 +13860,40 @@ 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 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 189 /* ClassExpression */: - case 217 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 218 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 156 /* TypeLiteral */: - case 168 /* ObjectLiteralExpression */: - case 218 /* InterfaceDeclaration */: + case 157 /* TypeLiteral */: + case 169 /* ObjectLiteralExpression */: + case 219 /* InterfaceDeclaration */: + case 261 /* JSDocRecordType */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // 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 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 219 /* TypeAliasDeclaration */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 265 /* JSDocFunctionType */: + case 220 /* 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 @@ -13650,7 +13904,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 64 /* Static */ + return node.flags & 32 /* Static */ ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -13660,11 +13914,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 251 /* SourceFile */ ? node : node.body; - if (body.kind === 251 /* SourceFile */ || body.kind === 222 /* ModuleBlock */) { + var body = node.kind === 252 /* SourceFile */ ? node : node.body; + if (body.kind === 252 /* SourceFile */ || body.kind === 223 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 231 /* ExportDeclaration */ || stat.kind === 230 /* ExportAssignment */) { + if (stat.kind === 232 /* ExportDeclaration */ || stat.kind === 231 /* ExportAssignment */) { return true; } } @@ -13675,16 +13929,16 @@ var ts; // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 131072 /* ExportContext */; + node.flags |= 8192 /* ExportContext */; } else { - node.flags &= ~131072 /* ExportContext */; + node.flags &= ~8192 /* ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); @@ -13743,7 +13997,7 @@ var ts; continue; } var identifier = prop.name; - // ECMA-262 11.1.5 Object Initialiser + // ECMA-262 11.1.5 Object Initializer // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and // IsDataDescriptor(propId.descriptor) is true. @@ -13751,7 +14005,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 === 248 /* PropertyAssignment */ || prop.kind === 249 /* ShorthandPropertyAssignment */ || prop.kind === 144 /* MethodDeclaration */ + var currentKind = prop.kind === 249 /* PropertyAssignment */ || prop.kind === 250 /* ShorthandPropertyAssignment */ || prop.kind === 145 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -13773,10 +14027,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -13873,7 +14127,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 32768 /* OctalLiteral */) { + if (inStrictMode && node.isOctalLiteral) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -13936,17 +14190,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 251 /* SourceFile */: - case 222 /* ModuleBlock */: + case 252 /* SourceFile */: + case 223 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 195 /* Block */: + case 196 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -13976,7 +14230,7 @@ var ts; /* Strict mode checks */ case 69 /* Identifier */: return checkStrictModeIdentifier(node); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -14000,97 +14254,100 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return checkStrictModeCatchClause(node); - case 178 /* DeleteExpression */: + case 179 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 183 /* PostfixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 208 /* WithStatement */: + case 209 /* WithStatement */: return checkStrictModeWithStatement(node); - case 162 /* ThisType */: + case 163 /* ThisType */: seenThisKeyword = true; return; - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: return checkTypePredicate(node); - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 139 /* Parameter */: + case 140 /* Parameter */: return bindParameter(node); - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 262 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 248 /* PropertyAssignment */: - case 249 /* ShorthandPropertyAssignment */: + case 249 /* PropertyAssignment */: + case 250 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* 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 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 145 /* Constructor */: + case 146 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 146 /* GetAccessor */: + case 147 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 147 /* SetAccessor */: + case 148 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 265 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 156 /* TypeLiteral */: + case 157 /* TypeLiteral */: + case 261 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return bindFunctionExpression(node); - case 171 /* CallExpression */: + case 172 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 189 /* ClassExpression */: - case 217 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 218 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 224 /* ImportEqualsDeclaration */: - case 227 /* NamespaceImport */: - case 229 /* ImportSpecifier */: - case 233 /* ExportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 228 /* NamespaceImport */: + case 230 /* ImportSpecifier */: + case 234 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 226 /* ImportClause */: + case 227 /* ImportClause */: return bindImportClause(node); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return bindExportDeclaration(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return bindExportAssignment(node); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -14099,7 +14356,7 @@ var ts; if (parameterName && parameterName.kind === 69 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 162 /* ThisType */) { + if (parameterName && parameterName.kind === 163 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -14114,12 +14371,12 @@ var ts; bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } function bindExportAssignment(node) { - var boundExpression = node.kind === 230 /* ExportAssignment */ ? node.expression : node.right; + var boundExpression = node.kind === 231 /* ExportAssignment */ ? node.expression : node.right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (boundExpression.kind === 69 /* Identifier */) { + else if (boundExpression.kind === 69 /* Identifier */ && node.kind === 231 /* ExportAssignment */) { // 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 */); } @@ -14162,17 +14419,24 @@ var ts; } function bindThisPropertyAssignment(node) { // Declare a 'member' in case it turns out the container was an ES5 class - if (container.kind === 176 /* FunctionExpression */ || container.kind === 216 /* FunctionDeclaration */) { + if (container.kind === 177 /* FunctionExpression */ || container.kind === 217 /* FunctionDeclaration */) { container.symbol.members = container.symbol.members || {}; - declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */ & ~4 /* Property */); } } function bindPrototypePropertyAssignment(node) { // We saw a node of the form 'x.prototype.y = z'. Declare a 'member' y on x if x was a function. // Look up the function in the local scope, since prototype assignments should // follow the function declaration - var classId = node.left.expression.expression; - var funcSymbol = container.locals[classId.text]; + var leftSideOfAssignment = node.left; + var classPrototype = leftSideOfAssignment.expression; + var constructorFunction = classPrototype.expression; + // Fix up parent pointers since we're going to use these nodes before we bind into them + leftSideOfAssignment.parent = node; + constructorFunction.parent = classPrototype; + classPrototype.parent = leftSideOfAssignment; + var funcSymbol = container.locals[constructorFunction.text]; if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */)) { return; } @@ -14181,12 +14445,12 @@ var ts; funcSymbol.members = {}; } // Declare the method/property - declareSymbol(funcSymbol.members, funcSymbol, node.left, 4 /* Property */, 107455 /* PropertyExcludes */); + declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4 /* Property */, 107455 /* PropertyExcludes */); } function bindCallExpression(node) { // We're only inspecting call expressions to detect CommonJS modules, so we can skip // this check if we've already seen the module indicator - if (!file.commonJsModuleIndicator && ts.isRequireCall(node)) { + if (!file.commonJsModuleIndicator && ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ false)) { setCommonJsModuleIndicator(node); } } @@ -14199,7 +14463,7 @@ var ts; hasDecorators = true; } } - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -14323,12 +14587,12 @@ var ts; if (ts.hasProperty(labelIndexMap, name.text)) { return false; } - labelIndexMap[name.text] = labelStack.push(1 /* Unintialized */) - 1; + labelIndexMap[name.text] = labelStack.push(1 /* Uninitialized */) - 1; return true; } function pushImplicitLabel() { initializeReachabilityStateIfNecessary(); - var index = labelStack.push(1 /* Unintialized */) - 1; + var index = labelStack.push(1 /* Uninitialized */) - 1; implicitLabels.push(index); return index; } @@ -14350,7 +14614,7 @@ var ts; setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); } function setCurrentStateAtLabel(innerMergedState, outerState, label) { - if (innerMergedState === 1 /* Unintialized */) { + if (innerMergedState === 1 /* Uninitialized */) { if (label && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); } @@ -14369,7 +14633,7 @@ var ts; return false; } var stateAtLabel = labelStack[index]; - labelStack[index] = stateAtLabel === 1 /* Unintialized */ ? outerState : or(stateAtLabel, outerState); + labelStack[index] = stateAtLabel === 1 /* Uninitialized */ ? outerState : or(stateAtLabel, outerState); return true; } function checkUnreachable(node) { @@ -14377,13 +14641,13 @@ var ts; case 4 /* Unreachable */: var reportError = // report error on all statements except empty ones - (ts.isStatement(node) && node.kind !== 197 /* EmptyStatement */) || + (ts.isStatement(node) && node.kind !== 198 /* EmptyStatement */) || // report error on class declarations - node.kind === 217 /* ClassDeclaration */ || + node.kind === 218 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 221 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 222 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 220 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 221 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentReachabilityState = 8 /* ReportedUnreachable */; // unreachable code is reported if @@ -14397,8 +14661,8 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 196 /* VariableStatement */ || - ts.getCombinedNodeFlags(node.declarationList) & 24576 /* BlockScoped */ || + (node.kind !== 197 /* VariableStatement */ || + ts.getCombinedNodeFlags(node.declarationList) & 3072 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); @@ -14469,8 +14733,8 @@ var ts; var emptySymbols = {}; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; - var modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === 2 /* ES6 */ ? 5 /* ES6 */ : 0 /* None */; - var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === 4 /* System */; + var modulekind = ts.getEmitModuleKind(compilerOptions); + var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; var emitResolver = createResolver(); var undefinedSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "undefined"); undefinedSymbol.declarations = []; @@ -14540,14 +14804,16 @@ var ts; // 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, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + var anySignature = createSignature(undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var globals = {}; var globalESSymbolConstructorSymbol; var getGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; + var globalReadonlyArrayType; var globalStringType; var globalNumberType; var globalBooleanType; @@ -14558,6 +14824,7 @@ var ts; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; + var anyReadonlyArrayType; var getGlobalClassDecoratorType; var getGlobalParameterDecoratorType; var getGlobalPropertyDecoratorType; @@ -14719,7 +14986,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 221 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 221 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 222 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 222 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -14739,13 +15006,13 @@ var ts; recordMergedSymbol(target, source); } else { - var message = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(source.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); + error(node.name ? node.name : node, message_2, symbolToString(source)); }); ts.forEach(target.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); + error(node.name ? node.name : node, message_2, symbolToString(source)); }); } } @@ -14778,8 +15045,8 @@ var ts; var moduleAugmentation = moduleName.parent; if (moduleAugmentation.symbol.valueDeclaration !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. - // its symbol already has accumulated information for all declarations - // so we need to add it just once - do the work only for first declaration + // its symbol already has accumulated information for all declarations + // so we need to add it just once - do the work only for first declaration ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1); return; } @@ -14787,15 +15054,22 @@ var ts; mergeSymbolTable(globals, moduleAugmentation.symbol.exports); } else { - // find a module that about to be augmented + // find a module that about to be augmented var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found); if (!mainModule) { return; } - // if module symbol has already been merged - it is safe to use it. - // otherwise clone it - mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); - mergeSymbol(mainModule, moduleAugmentation.symbol); + // obtain item referenced by 'export=' + mainModule = resolveExternalModuleSymbol(mainModule); + if (mainModule.flags & 1536 /* Namespace */) { + // if module symbol has already been merged - it is safe to use it. + // otherwise clone it + mainModule = mainModule.flags & 33554432 /* Merged */ ? mainModule : cloneSymbol(mainModule); + mergeSymbol(mainModule, moduleAugmentation.symbol); + } + else { + error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text); + } } } function addToSymbolTable(target, source, message) { @@ -14825,7 +15099,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function isGlobalSourceFile(node) { - return node.kind === 251 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 252 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -14851,9 +15125,9 @@ var ts; * @return a tuple of two symbols */ function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { - var constructoDeclaration = parameter.parent; + var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructoDeclaration.locals, parameterName, 107455 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 107455 /* Value */); var propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, 107455 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; @@ -14874,7 +15148,7 @@ var ts; if (declaration.pos <= usage.pos) { // declaration is before usage // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 214 /* VariableDeclaration */ || + return declaration.kind !== 215 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -14882,14 +15156,14 @@ var ts; return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); - if (declaration.parent.parent.kind === 196 /* VariableStatement */ || - declaration.parent.parent.kind === 202 /* ForStatement */) { + if (declaration.parent.parent.kind === 197 /* VariableStatement */ || + declaration.parent.parent.kind === 203 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) return isSameScopeDescendentOf(usage, declaration, container); } - else if (declaration.parent.parent.kind === 204 /* ForOfStatement */ || - declaration.parent.parent.kind === 203 /* ForInStatement */) { + else if (declaration.parent.parent.kind === 205 /* ForOfStatement */ || + declaration.parent.parent.kind === 204 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = declaration.parent.parent.expression; return isSameScopeDescendentOf(usage, expression, container); @@ -14906,8 +15180,8 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 142 /* PropertyDeclaration */ && - (current.parent.flags & 64 /* Static */) === 0 && + current.parent.kind === 143 /* PropertyDeclaration */ && + (current.parent.flags & 32 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -14936,11 +15210,13 @@ var ts; // - Type parameters of a function are in scope in the entire function declaration, including the parameter // list and return type. However, local types are only in scope in the function body. // - parameters are only in the scope of function body - if (meaning & result.flags & 793056 /* Type */) { + // This restriction does not apply to JSDoc comment types because they are parented + // at a higher level than type parameters would normally be + if (meaning & result.flags & 793056 /* Type */ && lastLocation.kind !== 269 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 139 /* Parameter */ || - lastLocation.kind === 138 /* TypeParameter */ + lastLocation.kind === 140 /* Parameter */ || + lastLocation.kind === 139 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -14949,9 +15225,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 139 /* Parameter */ || + lastLocation.kind === 140 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 139 /* Parameter */); + result.valueDeclaration.kind === 140 /* Parameter */); } } if (useResult) { @@ -14963,12 +15239,12 @@ var ts; } } switch (location.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 251 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 252 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports["default"]) { @@ -14991,7 +15267,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 233 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 234 /* ExportSpecifier */)) { break; } } @@ -14999,20 +15275,20 @@ var ts; break loop; } break; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(location.flags & 64 /* Static */)) { + if (ts.isClassLike(location.parent) && !(location.flags & 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -15022,11 +15298,11 @@ var ts; } } break; - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { - if (lastLocation && lastLocation.flags & 64 /* Static */) { + if (lastLocation && lastLocation.flags & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. @@ -15035,7 +15311,7 @@ var ts; } break loop; } - if (location.kind === 189 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 190 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -15051,9 +15327,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 218 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 219 /* 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); @@ -15061,19 +15337,19 @@ var ts; } } break; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 176 /* FunctionExpression */: + case 177 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -15086,7 +15362,7 @@ var ts; } } break; - case 140 /* Decorator */: + case 141 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -15095,7 +15371,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 === 139 /* Parameter */) { + if (location.parent && location.parent.kind === 140 /* Parameter */) { location = location.parent; } // @@ -15171,8 +15447,8 @@ var ts; return true; } // No static member is present. - // Check if we're in an instance method and look for a relevant instance member. - if (location === container && !(location.flags & 64 /* Static */)) { + // Check if we're in an instance method and look for a relevant instance member. + if (location === container && !(location.flags & 32 /* Static */)) { var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); @@ -15189,7 +15465,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 214 /* VariableDeclaration */), errorLocation)) { + if (!isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 215 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -15210,10 +15486,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 224 /* ImportEqualsDeclaration */) { + if (node.kind === 225 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 225 /* ImportDeclaration */) { + while (node && node.kind !== 226 /* ImportDeclaration */) { node = node.parent; } return node; @@ -15223,7 +15499,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 235 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 236 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -15236,7 +15512,7 @@ var ts; error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { - return resolveSymbol(moduleSymbol.exports["export="]) || resolveSymbol(moduleSymbol); + return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } return exportDefaultSymbol; } @@ -15325,17 +15601,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 226 /* ImportClause */: + case 227 /* ImportClause */: return getTargetOfImportClause(node); - case 227 /* NamespaceImport */: + case 228 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 229 /* ImportSpecifier */: + case 230 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 233 /* ExportSpecifier */: + case 234 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -15380,11 +15656,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 230 /* ExportAssignment */) { + if (node.kind === 231 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 233 /* ExportSpecifier */) { + else if (node.kind === 234 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -15397,7 +15673,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 224 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 225 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -15410,13 +15686,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 136 /* QualifiedName */) { + if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 137 /* 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 === 224 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 225 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -15436,9 +15712,9 @@ var ts; return undefined; } } - else if (name.kind === 136 /* QualifiedName */ || name.kind === 169 /* PropertyAccessExpression */) { - var left = name.kind === 136 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 136 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 137 /* QualifiedName */ || name.kind === 170 /* PropertyAccessExpression */) { + var left = name.kind === 137 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 137 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -15487,7 +15763,7 @@ var ts; return getMergedSymbol(sourceFile.symbol); } if (moduleNotFoundError) { - // report errors only if it was requested + // report errors only if it was requested error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName); } return undefined; @@ -15501,7 +15777,7 @@ var ts; // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && resolveSymbol(moduleSymbol.exports["export="]) || moduleSymbol; + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports["export="])) || moduleSymbol; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may @@ -15514,8 +15790,8 @@ var ts; } return symbol; } - function getExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports["export="]; + function hasExportAssignmentSymbol(moduleSymbol) { + return moduleSymbol.exports["export="] !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -15624,7 +15900,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 145 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 146 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -15671,19 +15947,19 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { + function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; + if (stringIndexInfo) + type.stringIndexInfo = stringIndexInfo; + if (numberIndexInfo) + type.numberIndexInfo = numberIndexInfo; return type; } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -15695,17 +15971,17 @@ var ts; } } switch (location_1.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -15732,7 +16008,7 @@ var ts; function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) - // and if symbolfrom symbolTable or alias resolution matches the symbol, + // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && canQualifySymbol(symbolFromSymbolTable, meaning); @@ -15746,7 +16022,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 233 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 234 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -15783,7 +16059,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, 233 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 234 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -15856,7 +16132,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 251 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 252 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -15870,7 +16146,7 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 2 /* Export */) && + !(anyImportSyntax.flags & 1 /* Export */) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -15892,12 +16168,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 155 /* TypeQuery */) { + if (entityName.parent.kind === 156 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 136 /* QualifiedName */ || entityName.kind === 169 /* PropertyAccessExpression */ || - entityName.parent.kind === 224 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 137 /* QualifiedName */ || entityName.kind === 170 /* PropertyAccessExpression */ || + entityName.parent.kind === 225 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -15949,13 +16225,29 @@ var ts; } return result; } + function typePredicateToString(typePredicate, enclosingDeclaration, flags) { + var writer = ts.getSingleLineStringWriter(); + getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); + var result = writer.string(); + ts.releaseStringWriter(writer); + return result; + } + function visibilityToString(flags) { + if (flags === 8 /* Private */) { + return "private"; + } + if (flags === 16 /* Protected */) { + return "protected"; + } + return "public"; + } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 161 /* ParenthesizedType */) { + while (node.kind === 162 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 219 /* TypeAliasDeclaration */) { + if (node.kind === 220 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -15963,7 +16255,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 222 /* ModuleBlock */ && + node.parent.kind === 223 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function getSymbolDisplayBuilder() { @@ -15974,10 +16266,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: return "(Anonymous class)"; - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -16065,16 +16357,10 @@ var ts; function writeType(type, flags) { // Write undefined/null type as any if (type.flags & 16777343 /* Intrinsic */) { - if (type.flags & 134217728 /* PredicateType */) { - buildTypePredicateDisplay(writer, type.predicate); - buildTypeDisplay(type.predicate.type, writer, enclosingDeclaration, flags, symbolStack); - } - else { - // 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" - : type.intrinsicName); - } + // 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" + : type.intrinsicName); } else if (type.flags & 33554432 /* ThisType */) { if (inObjectTypeLiteral) { @@ -16159,14 +16445,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_3 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_4 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_4); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_3, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_4, typeArguments, start, i, flags); writePunctuation(writer, 21 /* DotToken */); } } @@ -16228,11 +16514,11 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64 /* Static */; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 32 /* Static */; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 251 /* SourceFile */ || declaration.parent.kind === 222 /* ModuleBlock */; + return declaration.parent.kind === 252 /* SourceFile */ || declaration.parent.kind === 223 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -16246,19 +16532,38 @@ var ts; writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } - function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); - if (!declaration) { - // declaration might not be found if indexer was added from the contextual type. - // in this case use fallback name - return fallbackName; + function writeIndexSignature(info, keyword) { + if (info) { + if (info.isReadonly) { + writeKeyword(writer, 127 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, keyword); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 54 /* ColonToken */); + writeSpace(writer); + writeType(info.type, 0 /* None */); + writePunctuation(writer, 23 /* SemicolonToken */); + writer.writeLine(); + } + } + function writePropertyWithModifiers(prop) { + if (isReadonlySymbol(prop)) { + writeKeyword(writer, 127 /* ReadonlyKeyword */); + writeSpace(writer); + } + buildSymbolDisplay(prop, writer); + if (prop.flags & 536870912 /* Optional */) { + writePunctuation(writer, 53 /* QuestionToken */); } - ts.Debug.assert(declaration.parameters.length !== 0); - return ts.declarationNameToString(declaration.parameters[0].name); } function writeLiteralType(type, flags) { var resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 15 /* OpenBraceToken */); writePunctuation(writer, 16 /* CloseBraceToken */); @@ -16304,34 +16609,8 @@ var ts; writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } - if (resolved.stringIndexType) { - // [x: string]: - writePunctuation(writer, 19 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 130 /* StringKeyword */); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.numberIndexType) { - // [x: number]: - writePunctuation(writer, 19 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 128 /* NumberKeyword */); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); - writeSpace(writer); - writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); - writer.writeLine(); - } + writeIndexSignature(resolved.stringIndexInfo, 131 /* StringKeyword */); + writeIndexSignature(resolved.numberIndexInfo, 129 /* NumberKeyword */); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -16339,20 +16618,14 @@ var ts; var signatures = getSignaturesOfType(t, 0 /* Call */); for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { var signature = signatures_1[_f]; - buildSymbolDisplay(p, writer); - if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); - } + writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } else { - buildSymbolDisplay(p, writer); - if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); - } + writePropertyWithModifiers(p); writePunctuation(writer, 54 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); @@ -16365,10 +16638,10 @@ var ts; inObjectTypeLiteral = saveInObjectTypeLiteral; } } - function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { + function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { var targetSymbol = getTargetSymbol(symbol); if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { - buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); + buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaration, flags); } } function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, symbolStack) { @@ -16431,7 +16704,7 @@ var ts; } writePunctuation(writer, 18 /* CloseParenToken */); } - function buildTypePredicateDisplay(writer, predicate) { + function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } @@ -16441,6 +16714,7 @@ var ts; writeSpace(writer); writeKeyword(writer, 124 /* IsKeyword */); writeSpace(writer); + buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { @@ -16451,8 +16725,13 @@ var ts; writePunctuation(writer, 54 /* ColonToken */); } writeSpace(writer); - var returnType = getReturnTypeOfSignature(signature); - buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + if (signature.typePredicate) { + buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack); + } + else { + var returnType = getReturnTypeOfSignature(signature); + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); + } } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1 /* Construct */) { @@ -16474,6 +16753,7 @@ var ts; buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, + buildTypePredicateDisplay: buildTypePredicateDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, @@ -16493,74 +16773,74 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 166 /* BindingElement */: + case 167 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 214 /* VariableDeclaration */: + case 215 /* 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 221 /* ModuleDeclaration */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 216 /* FunctionDeclaration */: - case 220 /* EnumDeclaration */: - case 224 /* ImportEqualsDeclaration */: + case 222 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 217 /* FunctionDeclaration */: + case 221 /* EnumDeclaration */: + case 225 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_4 = getDeclarationContainer(node); + var parent_5 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedNodeFlags(node) & 2 /* Export */) && - !(node.kind !== 224 /* ImportEqualsDeclaration */ && parent_4.kind !== 251 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { - return isGlobalSourceFile(parent_4); + if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && + !(node.kind !== 225 /* ImportEqualsDeclaration */ && parent_5.kind !== 252 /* SourceFile */ && ts.isInAmbientContext(parent_5))) { + return isGlobalSourceFile(parent_5); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_4); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - if (node.flags & (16 /* Private */ | 32 /* Protected */)) { + return isDeclarationVisible(parent_5); + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + if (node.flags & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 145 /* Constructor */: - case 149 /* ConstructSignature */: - case 148 /* CallSignature */: - case 150 /* IndexSignature */: - case 139 /* Parameter */: - case 222 /* ModuleBlock */: - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 156 /* TypeLiteral */: - case 152 /* TypeReference */: - case 157 /* ArrayType */: - case 158 /* TupleType */: - case 159 /* UnionType */: - case 160 /* IntersectionType */: - case 161 /* ParenthesizedType */: + case 146 /* Constructor */: + case 150 /* ConstructSignature */: + case 149 /* CallSignature */: + case 151 /* IndexSignature */: + case 140 /* Parameter */: + case 223 /* ModuleBlock */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 157 /* TypeLiteral */: + case 153 /* TypeReference */: + case 158 /* ArrayType */: + case 159 /* TupleType */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: + case 162 /* 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 226 /* ImportClause */: - case 227 /* NamespaceImport */: - case 229 /* ImportSpecifier */: + case 227 /* ImportClause */: + case 228 /* NamespaceImport */: + case 230 /* ImportSpecifier */: return false; // Type parameters are always visible - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: // Source file is always visible - case 251 /* SourceFile */: + case 252 /* SourceFile */: return true; // Export assignments do not create name bindings outside the module - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -16569,10 +16849,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 230 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 231 /* 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 === 233 /* ExportSpecifier */) { + else if (node.parent.kind === 234 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -16664,16 +16944,27 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - // Parent chain: - // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 214 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + while (node) { + switch (node.kind) { + case 215 /* VariableDeclaration */: + case 216 /* VariableDeclarationList */: + case 230 /* ImportSpecifier */: + case 229 /* NamedImports */: + case 228 /* NamespaceImport */: + case 227 /* ImportClause */: + node = node.parent; + break; + default: + return node.parent; + } + } } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 // Every class automatically contains a static property member named 'prototype', // the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter. // It is an error to explicitly declare a static property member with the name 'prototype'. - var classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); + var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)); return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } // Return the type of the given property in the given type, or undefined if no such property exists @@ -16697,7 +16988,7 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -16705,7 +16996,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 137 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 138 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); } // Return the inferred type for a binding element function getTypeForBindingElement(declaration) { @@ -16725,7 +17016,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 164 /* ObjectBindingPattern */) { + if (pattern.kind === 165 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_10)) { @@ -16771,13 +17062,53 @@ var ts; } return type; } + function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + var jsDocType = getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (jsDocType) { + return getTypeFromTypeNode(jsDocType); + } + } + function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration) { + // First, see if this node has an @type annotation on it directly. + var typeTag = ts.getJSDocTypeTag(declaration); + if (typeTag && typeTag.typeExpression) { + return typeTag.typeExpression.type; + } + if (declaration.kind === 215 /* VariableDeclaration */ && + declaration.parent.kind === 216 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 197 /* VariableStatement */) { + // @type annotation might have been on the variable statement, try that instead. + var annotation = ts.getJSDocTypeTag(declaration.parent.parent); + if (annotation && annotation.typeExpression) { + return annotation.typeExpression.type; + } + } + else if (declaration.kind === 140 /* Parameter */) { + // If it's a parameter, see if the parent has a jsdoc comment with an @param + // annotation. + var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type; + } + } + return undefined; + } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { + if (declaration.flags & 134217728 /* JavaScriptFile */) { + // If this is a variable in a JavaScript file, then use the JSDoc type (if it has + // one as its type), otherwise fallback to the below standard TS codepaths to + // try to figure it out. + var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); + if (type && type !== unknownType) { + return type; + } + } // A variable declared in a for..in statement is always of type string - if (declaration.parent.parent.kind === 203 /* ForInStatement */) { + if (declaration.parent.parent.kind === 204 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 204 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 205 /* 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, @@ -16791,11 +17122,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 139 /* Parameter */) { + if (declaration.kind === 140 /* 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 === 147 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 146 /* GetAccessor */); + if (func.kind === 148 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 147 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -16811,7 +17142,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 249 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 250 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -16867,7 +17198,7 @@ var ts; return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - var elementTypes = ts.map(elements, function (e) { return e.kind === 190 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + var elementTypes = ts.map(elements, function (e) { return e.kind === 191 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); if (includePatternInType) { var result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -16883,7 +17214,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType) { - return pattern.kind === 164 /* ObjectBindingPattern */ + return pattern.kind === 165 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType) : getTypeFromArrayBindingPattern(pattern, includePatternInType); } @@ -16905,10 +17236,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - if (declaration.kind === 248 /* PropertyAssignment */) { - return type; - } - if (type.flags & 134217728 /* PredicateType */ && (declaration.kind === 142 /* PropertyDeclaration */ || declaration.kind === 141 /* PropertySignature */)) { + if (declaration.kind === 249 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -16918,7 +17246,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 139 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 140 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -16933,21 +17261,21 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 247 /* CatchClause */) { + if (declaration.parent.kind === 248 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 230 /* ExportAssignment */) { + if (declaration.kind === 231 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle module.exports = expr - if (declaration.kind === 184 /* BinaryExpression */) { - return links.type = checkExpression(declaration.right); + if (declaration.kind === 185 /* BinaryExpression */) { + return links.type = getUnionType(ts.map(symbol.declarations, function (decl) { return checkExpressionCached(decl.right); })); } - if (declaration.kind === 169 /* PropertyAccessExpression */) { + if (declaration.kind === 170 /* PropertyAccessExpression */) { // Declarations only exist for property access expressions for certain // special assignment kinds - if (declaration.parent.kind === 184 /* BinaryExpression */) { + if (declaration.parent.kind === 185 /* BinaryExpression */) { // Handle exports.p = expr or this.p = expr or className.prototype.method = expr return links.type = checkExpressionCached(declaration.parent.right); } @@ -16977,7 +17305,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 146 /* GetAccessor */) { + if (accessor.kind === 147 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -16993,9 +17321,9 @@ var ts; if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 146 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 147 /* SetAccessor */); - var type; + var getter = ts.getDeclarationOfKind(symbol, 147 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 148 /* SetAccessor */); + var type = void 0; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -17023,7 +17351,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 146 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 147 /* 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)); } } @@ -17123,9 +17451,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 217 /* ClassDeclaration */ || node.kind === 189 /* ClassExpression */ || - node.kind === 216 /* FunctionDeclaration */ || node.kind === 176 /* FunctionExpression */ || - node.kind === 144 /* MethodDeclaration */ || node.kind === 177 /* ArrowFunction */) { + if (node.kind === 218 /* ClassDeclaration */ || node.kind === 190 /* ClassExpression */ || + node.kind === 217 /* FunctionDeclaration */ || node.kind === 177 /* FunctionExpression */ || + node.kind === 145 /* MethodDeclaration */ || node.kind === 178 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -17135,7 +17463,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, 218 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 219 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -17144,8 +17472,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 218 /* InterfaceDeclaration */ || node.kind === 217 /* ClassDeclaration */ || - node.kind === 189 /* ClassExpression */ || node.kind === 219 /* TypeAliasDeclaration */) { + if (node.kind === 219 /* InterfaceDeclaration */ || node.kind === 218 /* ClassDeclaration */ || + node.kind === 190 /* ClassExpression */ || node.kind === 220 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -17172,8 +17500,8 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { - var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments); }); + var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); + signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); } return signatures; } @@ -17285,7 +17613,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 218 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 219 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -17317,8 +17645,8 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 218 /* InterfaceDeclaration */) { - if (declaration.flags & 262144 /* ContainsThis */) { + if (declaration.kind === 219 /* InterfaceDeclaration */) { + if (declaration.flags & 16384 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -17373,7 +17701,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 219 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 220 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -17406,7 +17734,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 138 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 139 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -17457,16 +17785,16 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: case 103 /* VoidKeyword */: - case 163 /* StringLiteralType */: + case 164 /* StringLiteralType */: return true; - case 157 /* ArrayType */: + case 158 /* ArrayType */: return isIndependentType(node.elementType); - case 152 /* TypeReference */: + case 153 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -17479,7 +17807,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 145 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 146 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -17493,19 +17821,19 @@ var ts; // Returns true if the class or interface member given by the symbol is free of "this" references. The // function may return false for symbols that are actually free of "this" references because it is not // feasible to perform a complete analysis in all cases. In particular, property members with types - // inferred from their initializers and function members with inferred return types are convervatively + // inferred from their initializers and function members with inferred return types are conservatively // assumed not to be free of "this" references. function isIndependentMember(symbol) { if (symbol.declarations && symbol.declarations.length === 1) { var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -17544,8 +17872,8 @@ var ts; type.declaredProperties = getNamedMembers(symbol.members); type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); + type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); } return type; } @@ -17560,15 +17888,15 @@ var ts; var members = source.symbol.members; var callSignatures = source.declaredCallSignatures; var constructSignatures = source.declaredConstructSignatures; - var stringIndexType = source.declaredStringIndexType; - var numberIndexType = source.declaredNumberIndexType; + var stringIndexInfo = source.declaredStringIndexInfo; + var numberIndexInfo = source.declaredNumberIndexInfo; if (!ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); - stringIndexType = instantiateType(source.declaredStringIndexType, mapper); - numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); + numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); } var baseTypes = getBaseTypes(source); if (baseTypes.length) { @@ -17582,11 +17910,11 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); + stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0 /* String */); + numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1 /* Number */); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); @@ -17598,25 +17926,26 @@ var ts; type.typeArguments : ts.concatenate(type.typeArguments, [type]); resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { + function createSignature(declaration, typeParameters, parameters, resolvedReturnType, typePredicate, minArgumentCount, hasRestParameter, hasStringLiterals) { var sig = new Signature(checker); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; sig.resolvedReturnType = resolvedReturnType; + sig.typePredicate = typePredicate; sig.minArgumentCount = minArgumentCount; sig.hasRestParameter = hasRestParameter; sig.hasStringLiterals = hasStringLiterals; return sig; } function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); + return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; + return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); @@ -17649,7 +17978,7 @@ var ts; var arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); + setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { @@ -17715,45 +18044,50 @@ var ts; } return result || emptyArray; } - function getUnionIndexType(types, kind) { + function getUnionIndexInfo(types, kind) { var indexTypes = []; + var isAnyReadonly = false; for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { var type = types_1[_i]; - var indexType = getIndexTypeOfType(type, kind); - if (!indexType) { + var indexInfo = getIndexInfoOfType(type, kind); + if (!indexInfo) { return undefined; } - indexTypes.push(indexType); + indexTypes.push(indexInfo.type); + isAnyReadonly = isAnyReadonly || indexInfo.isReadonly; } - return getUnionType(indexTypes); + return createIndexInfo(getUnionType(indexTypes), isAnyReadonly); } function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). var callSignatures = getUnionSignatures(type.types, 0 /* Call */); var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); - var stringIndexType = getUnionIndexType(type.types, 0 /* String */); - var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); + var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } + function intersectIndexInfos(info1, info2) { + return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); + } function resolveIntersectionTypeMembers(type) { // The members and properties collections are empty for intersection types. To get all properties of an // intersection type use getPropertiesOfType (only the language service uses this). var callSignatures = emptyArray; var constructSignatures = emptyArray; - var stringIndexType = undefined; - var numberIndexType = undefined; + var stringIndexInfo = undefined; + var numberIndexInfo = undefined; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); - stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0 /* String */)); - numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1 /* Number */)); + stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0 /* String */)); + numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; @@ -17761,17 +18095,17 @@ var ts; var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); var constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); - var stringIndexType = instantiateType(getIndexTypeOfType(type.target, 0 /* String */), type.mapper); - var numberIndexType = instantiateType(getIndexTypeOfType(type.target, 1 /* Number */), type.mapper); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0 /* String */), type.mapper); + var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1 /* Number */), type.mapper); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; var callSignatures = getSignaturesOfSymbol(members["__call"]); var constructSignatures = getSignaturesOfSymbol(members["__new"]); - var stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - var numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); + var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); + setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { // Combinations of function, class, enum and module @@ -17792,8 +18126,8 @@ var ts; addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } - var numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexType); + var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; + setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list @@ -17912,7 +18246,7 @@ var ts; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 /* Private */ | 32 /* Protected */))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */))) { commonFlags &= prop.flags; if (!props) { props = [prop]; @@ -18002,17 +18336,48 @@ var ts; function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } - function getIndexTypeOfStructuredType(type, kind) { + function getIndexInfoOfStructuredType(type, kind) { if (type.flags & 130048 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; + return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } } + function getIndexTypeOfStructuredType(type, kind) { + var info = getIndexInfoOfStructuredType(type, kind); + return info && info.type; + } + // Return the indexing info of the given kind in the given type. Creates synthetic union index types when necessary and + // maps primitive types and type parameters are to their apparent types. + function getIndexInfoOfType(type, kind) { + return getIndexInfoOfStructuredType(getApparentType(type), kind); + } // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. function getIndexTypeOfType(type, kind) { return getIndexTypeOfStructuredType(getApparentType(type), kind); } + function getImplicitIndexTypeOfType(type, kind) { + if (isObjectLiteralType(type)) { + var propTypes = []; + for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + if (kind === 0 /* String */ || isNumericLiteralName(prop.name)) { + propTypes.push(getTypeOfSymbol(prop)); + } + } + return getUnionType(propTypes); + } + return undefined; + } + function getTypeParametersFromJSDocTemplate(declaration) { + if (declaration.flags & 134217728 /* JavaScriptFile */) { + var templateTag = ts.getJSDocTemplateTag(declaration); + if (templateTag) { + return getTypeParametersFromDeclaration(templateTag.typeParameters); + } + } + return undefined; + } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(typeParameterDeclarations) { @@ -18035,6 +18400,20 @@ var ts; return result; } function isOptionalParameter(node) { + if (node.flags & 134217728 /* JavaScriptFile */) { + if (node.type && node.type.kind === 264 /* JSDocOptionalType */) { + return true; + } + var paramTag = ts.getCorrespondingJSDocParameterTag(node); + if (paramTag) { + if (paramTag.isBracketed) { + return true; + } + if (paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 264 /* JSDocOptionalType */; + } + } + } if (ts.hasQuestionToken(node)) { return true; } @@ -18067,15 +18446,22 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 145 /* Constructor */ ? + var classType = declaration.kind === 146 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : - declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; + declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : + getTypeParametersFromJSDocTemplate(declaration); var parameters = []; var hasStringLiterals = false; var minArgumentCount = -1; - for (var i = 0, n = declaration.parameters.length; i < n; i++) { + var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); + var returnType = undefined; + var typePredicate = undefined; + // If this is a JSDoc construct signature, then skip the first parameter in the + // parameter list. The first parameter represents the return type of the construct + // signature. + for (var i = isJSConstructSignature ? 1 : 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature @@ -18084,7 +18470,7 @@ var ts; paramSymbol = resolvedSymbol; } parameters.push(paramSymbol); - if (param.type && param.type.kind === 163 /* StringLiteralType */) { + if (param.type && param.type.kind === 164 /* StringLiteralType */) { hasStringLiterals = true; } if (param.initializer || param.questionToken || param.dotDotDotToken) { @@ -18100,25 +18486,37 @@ var ts; if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; } - var returnType; - if (classType) { + if (isJSConstructSignature) { + minArgumentCount--; + returnType = getTypeFromTypeNode(declaration.parameters[0].type); + } + else if (classType) { returnType = classType; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); + if (declaration.type.kind === 152 /* TypePredicate */) { + typePredicate = createTypePredicateFromTypePredicateNode(declaration.type); + } } else { + if (declaration.flags & 134217728 /* JavaScriptFile */) { + var type = getReturnTypeFromJSDocComment(declaration); + if (type && type !== unknownType) { + returnType = type; + } + } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 146 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 147 /* SetAccessor */); + if (declaration.kind === 147 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 148 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { returnType = anyType; } } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); + links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasStringLiterals); } return links.resolvedSignature; } @@ -18129,19 +18527,20 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 265 /* JSDocFunctionType */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -18171,7 +18570,7 @@ var ts; if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } - var type; + var type = void 0; if (signature.target) { type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); } @@ -18228,7 +18627,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 === 145 /* Constructor */ || signature.declaration.kind === 149 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 146 /* Constructor */ || signature.declaration.kind === 150 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -18242,7 +18641,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 128 /* NumberKeyword */ : 130 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 129 /* NumberKeyword */ : 131 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -18258,18 +18657,22 @@ var ts; } return undefined; } - function getIndexTypeOfSymbol(symbol, kind) { + function createIndexInfo(type, isReadonly, declaration) { + return { type: type, isReadonly: isReadonly, declaration: declaration }; + } + function getIndexInfoOfSymbol(symbol, kind) { var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration - ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType - : undefined; + if (declaration) { + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, (declaration.flags & 64 /* Readonly */) !== 0, declaration); + } + return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 138 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 139 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; - while (type && type.flags & 512 /* TypeParameter */ && !ts.contains(checked, type)) { + while (type && !(type.flags & 33554432 /* ThisType */) && type.flags & 512 /* TypeParameter */ && !ts.contains(checked, type)) { if (type === target) { return true; } @@ -18298,7 +18701,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 138 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 139 /* TypeParameter */).parent); } function getTypeListId(types) { if (types) { @@ -18393,18 +18796,68 @@ var ts; } return getDeclaredTypeOfSymbol(symbol); } + function getTypeReferenceName(node) { + switch (node.kind) { + case 153 /* TypeReference */: + return node.typeName; + case 263 /* JSDocTypeReference */: + return node.name; + case 192 /* ExpressionWithTypeArguments */: + // We only support expressions that are simple qualified names. For other + // expressions this produces undefined. + if (ts.isSupportedExpressionWithTypeArguments(node)) { + return node.expression; + } + } + return undefined; + } + function resolveTypeReferenceName(node, typeReferenceName) { + if (!typeReferenceName) { + return unknownSymbol; + } + return resolveEntityName(typeReferenceName, 793056 /* Type */) || unknownSymbol; + } + function getTypeReferenceType(node, symbol) { + if (symbol === unknownSymbol) { + return unknownType; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); + } + if (symbol.flags & 107455 /* Value */ && node.kind === 263 /* JSDocTypeReference */) { + // A JSDocTypeReference may have resolved to a value (as opposed to a type). In + // that case, the type of this reference is just the type of the value we resolved + // to. + return getTypeOfSymbol(symbol); + } + return getTypeFromNonGenericTypeReference(node, symbol); + } function getTypeFromTypeReference(node) { 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 === 152 /* TypeReference */ ? node.typeName : - ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : - undefined; - var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; - var type = symbol === unknownSymbol ? unknownType : - symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + var symbol = void 0; + var type = void 0; + if (node.kind === 263 /* JSDocTypeReference */) { + var typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(node, typeReferenceName); + type = getTypeReferenceType(node, symbol); + links.resolvedSymbol = symbol; + links.resolvedType = type; + } + else { + // We only support expressions that are simple qualified names. For other expressions this produces undefined. + var typeNameOrExpression = node.kind === 153 /* TypeReference */ ? node.typeName : + ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : + undefined; + symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; + type = symbol === unknownSymbol ? unknownType : + symbol.flags & (32 /* Class */ | 64 /* Interface */) ? getTypeFromClassOrInterfaceReference(node, symbol) : + symbol.flags & 524288 /* TypeAlias */ ? getTypeFromTypeAliasReference(node, symbol) : + getTypeFromNonGenericTypeReference(node, symbol); + } // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the // type reference in checkTypeReferenceOrExpressionWithTypeArguments. links.resolvedSymbol = symbol; @@ -18429,9 +18882,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: return declaration; } } @@ -18669,12 +19122,28 @@ var ts; } return links.resolvedType; } + function getTypeFromJSDocVariadicType(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var type = getTypeFromTypeNode(node.type); + links.resolvedType = type ? createArrayType(type) : unknownType; + } + return links.resolvedType; + } + function getTypeFromJSDocTupleType(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var types = ts.map(node.types, getTypeFromTypeNode); + links.resolvedType = createTupleType(types); + } + return links.resolvedType; + } function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 218 /* InterfaceDeclaration */)) { - if (!(container.flags & 64 /* Static */) && - (container.kind !== 145 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { + if (parent && (ts.isClassLike(parent) || parent.kind === 219 /* InterfaceDeclaration */)) { + if (!(container.flags & 32 /* Static */) && + (container.kind !== 146 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -18688,68 +19157,68 @@ var ts; } return links.resolvedType; } - function getPredicateType(node) { - return createPredicateType(getSymbolOfNode(node), createTypePredicateFromTypePredicateNode(node)); - } - function createPredicateType(symbol, predicate) { - var type = createType(8 /* Boolean */ | 134217728 /* PredicateType */); - type.symbol = symbol; - type.predicate = predicate; - return type; - } - function getTypeFromPredicateTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getPredicateType(node); - } - return links.resolvedType; - } function getTypeFromTypeNode(node) { switch (node.kind) { case 117 /* AnyKeyword */: + case 254 /* JSDocAllType */: + case 255 /* JSDocUnknownType */: return anyType; - case 130 /* StringKeyword */: + case 131 /* StringKeyword */: return stringType; - case 128 /* NumberKeyword */: + case 129 /* NumberKeyword */: return numberType; case 120 /* BooleanKeyword */: return booleanType; - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: return esSymbolType; case 103 /* VoidKeyword */: return voidType; - case 162 /* ThisType */: + case 163 /* ThisType */: return getTypeFromThisTypeNode(node); - case 163 /* StringLiteralType */: + case 164 /* StringLiteralType */: return getTypeFromStringLiteralTypeNode(node); - case 152 /* TypeReference */: + case 153 /* TypeReference */: + case 263 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 151 /* TypePredicate */: - return getTypeFromPredicateTypeNode(node); - case 191 /* ExpressionWithTypeArguments */: + case 152 /* TypePredicate */: + return booleanType; + case 192 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 157 /* ArrayType */: + case 158 /* ArrayType */: + case 256 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 158 /* TupleType */: + case 159 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 159 /* UnionType */: + case 160 /* UnionType */: + case 257 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); - case 160 /* IntersectionType */: + case 161 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: + case 259 /* JSDocNullableType */: + case 260 /* JSDocNonNullableType */: + case 267 /* JSDocConstructorType */: + case 268 /* JSDocThisType */: + case 264 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 156 /* TypeLiteral */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 157 /* TypeLiteral */: + case 265 /* JSDocFunctionType */: + case 261 /* JSDocRecordType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 69 /* Identifier */: - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); + case 258 /* JSDocTupleType */: + return getTypeFromJSDocTupleType(node); + case 266 /* JSDocVariadicType */: + return getTypeFromJSDocVariadicType(node); default: return unknownType; } @@ -18853,6 +19322,7 @@ var ts; } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; + var freshTypePredicate; if (signature.typeParameters && !eraseTypeParameters) { // First create a fresh set of type parameters, then include a mapping from the old to the // new type parameters in the mapper function. Finally store this mapper in the new type @@ -18864,7 +19334,10 @@ var ts; tp.mapper = mapper; } } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); + if (signature.typePredicate) { + freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper); + } + var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; result.mapper = mapper; return result; @@ -18928,37 +19401,36 @@ var ts; if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); } - if (type.flags & 134217728 /* PredicateType */) { - var predicate = type.predicate; - return createPredicateType(type.symbol, cloneTypePredicate(predicate, mapper)); - } } return type; } + function instantiateIndexInfo(info, mapper) { + return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); + } // 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 !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return node.operatorToken.kind === 52 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 248 /* PropertyAssignment */: + case 249 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -19045,18 +19517,48 @@ var ts; } var sourceReturnType = getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions - if (targetReturnType.flags & 134217728 /* PredicateType */ && targetReturnType.predicate.kind === 1 /* Identifier */) { - if (!(sourceReturnType.flags & 134217728 /* PredicateType */)) { + if (target.typePredicate) { + if (source.typePredicate) { + result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes); + } + else if (ts.isIdentifierTypePredicate(target.typePredicate)) { if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source)); } return 0 /* False */; } } - result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + else { + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + } } return result; } + function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) { + if (source.kind !== target.kind) { + if (reportErrors) { + errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return 0 /* False */; + } + if (source.kind === 1 /* Identifier */) { + var sourceIdentifierPredicate = source; + var targetIdentifierPredicate = target; + if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { + if (reportErrors) { + errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return 0 /* False */; + } + } + var related = compareTypes(source.type, target.type, reportErrors); + if (related === 0 /* False */ && reportErrors) { + errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); + } + return related; + } function isImplementationCompatibleWithOverload(implementation, overload) { var erasedSource = getErasedSignature(implementation); var erasedTarget = getErasedSignature(overload); @@ -19171,33 +19673,6 @@ var ts; return -1 /* True */; } if (source.flags & 8 /* Boolean */ && target.flags & 8 /* Boolean */) { - if (source.flags & 134217728 /* PredicateType */ && target.flags & 134217728 /* PredicateType */) { - var sourcePredicate = source; - var targetPredicate = target; - if (sourcePredicate.predicate.kind !== targetPredicate.predicate.kind) { - if (reportErrors) { - reportError(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - if (sourcePredicate.predicate.kind === 1 /* Identifier */) { - var sourceIdentifierPredicate = sourcePredicate.predicate; - var targetIdentifierPredicate = targetPredicate.predicate; - if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) { - if (reportErrors) { - reportError(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName); - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - } - var related = isRelatedTo(sourcePredicate.predicate.type, targetPredicate.predicate.type, reportErrors, headMessage); - if (related === 0 /* False */ && reportErrors) { - reportError(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target)); - } - return related; - } return -1 /* True */; } if (source.flags & 1048576 /* FreshObjectLiteral */) { @@ -19311,7 +19786,7 @@ var ts; if (type.flags & 80896 /* ObjectType */) { var resolved = resolveStructuredTypeMembers(type); if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || - resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + resolved.stringIndexInfo || resolved.numberIndexInfo || getPropertyOfType(type, name)) { return true; } } @@ -19326,7 +19801,7 @@ var ts; return false; } function hasExcessProperties(source, target, reportErrors) { - if (!(target.flags & 67108864 /* ObjectLiteralPatternWithComputedProperties */) && someConstituentTypeHasKind(target, 80896 /* ObjectType */)) { + if (!(target.flags & 67108864 /* ObjectLiteralPatternWithComputedProperties */) && maybeTypeOfKind(target, 80896 /* ObjectType */)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -19480,9 +19955,9 @@ var ts; if (result) { result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors); if (result) { - result &= stringIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, 0 /* String */, reportErrors); if (result) { - result &= numberIndexTypesRelatedTo(source, originalSource, target, reportErrors); + result &= indexTypesRelatedTo(source, originalSource, target, 1 /* Number */, reportErrors); } } } @@ -19525,23 +20000,23 @@ var ts; else if (!(targetProp.flags & 134217728 /* Prototype */)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 16 /* Private */ || targetPropFlags & 16 /* Private */) { + if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 16 /* Private */ && targetPropFlags & 16 /* Private */) { + if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 /* Private */ ? source : target), typeToString(sourcePropFlags & 16 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); } } return 0 /* False */; } } - else if (targetPropFlags & 32 /* Protected */) { + else if (targetPropFlags & 16 /* Protected */) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(getParentOfSymbol(sourceProp)) : undefined; + var targetClass = getDeclaredTypeOfSymbol(getParentOfSymbol(targetProp)); if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); @@ -19549,7 +20024,7 @@ var ts; return 0 /* False */; } } - else if (sourcePropFlags & 32 /* Protected */) { + else if (sourcePropFlags & 16 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -19614,43 +20089,41 @@ var ts; } var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length && - isAbstractConstructorType(source) && !isAbstractConstructorType(target)) { - // An abstract constructor type is not assignable to a non-abstract constructor type - // as it would otherwise be possible to new an abstract class. Note that the assignablity - // check we perform for an extends clause excludes construct signatures from the target, - // so this check never proceeds. - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { + if (isAbstractConstructorType(source) && !isAbstractConstructorType(target)) { + // An abstract constructor type is not assignable to a non-abstract constructor type + // as it would otherwise be possible to new an abstract class. Note that the assignability + // check we perform for an extends clause excludes construct signatures from the target, + // so this check never proceeds. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { + return 0 /* False */; } - return 0 /* False */; } var result = -1 /* True */; var saveErrorInfo = errorInfo; outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { var t = targetSignatures_1[_i]; - if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { - // Only elaborate errors from the first failure - var shouldElaborateErrors = reportErrors; - for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { - var s = sourceSignatures_1[_a]; - if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { - var related = signatureRelatedTo(s, t, shouldElaborateErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; - } - shouldElaborateErrors = false; - } + // Only elaborate errors from the first failure + var shouldElaborateErrors = reportErrors; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; + var related = signatureRelatedTo(s, t, shouldElaborateErrors); + if (related) { + result &= related; + errorInfo = saveErrorInfo; + continue outer; } - // don't elaborate the primitive apparent types (like Number) - // because the actual primitives will have already been reported. - if (shouldElaborateErrors) { - reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); - } - return 0 /* False */; + shouldElaborateErrors = false; } + if (shouldElaborateErrors) { + reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); + } + return 0 /* False */; } return result; } @@ -19676,80 +20149,70 @@ var ts; } return result; } - function stringIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0 /* String */, source, target); - } - var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { - if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: string]: any } = { property: 12 };` - return -1 /* True */; - } - var sourceType = getIndexTypeOfType(source, 0 /* String */); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + function eachPropertyRelatedTo(source, target, kind, reportErrors) { + var result = -1 /* True */; + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (kind === 0 /* String */ || isNumericLiteralName(prop.name)) { + var related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); + } + return 0 /* False */; } - return 0 /* False */; + result &= related; } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; } - return -1 /* True */; + return result; } - function numberIndexTypesRelatedTo(source, originalSource, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1 /* Number */, source, target); + function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { + var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors); + if (!related && reportErrors) { + reportError(ts.Diagnostics.Index_signatures_are_incompatible); } - var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { - if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg - // `var x: { [index: number]: any } = { property: 12 };` - return -1 /* True */; - } - var sourceStringType = getIndexTypeOfType(source, 0 /* String */); - var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; - } - var related; - if (sourceStringType && sourceNumberType) { - // If we know for sure we're testing both string and numeric index types then only report errors from the second one - related = isRelatedTo(sourceStringType, targetType, /*reportErrors*/ false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; - } - return -1 /* True */; + return related; } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { + function indexTypesRelatedTo(source, originalSource, target, kind, reportErrors) { + if (relation === identityRelation) { + return indexTypesIdenticalTo(source, target, kind); + } + var targetInfo = getIndexInfoOfType(target, kind); + if (!targetInfo || ((targetInfo.type.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */))) { + // Index signature of type any permits assignment from everything but primitives return -1 /* True */; } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); + var sourceInfo = getIndexInfoOfType(source, kind) || + kind === 1 /* Number */ && getIndexInfoOfType(source, 0 /* String */); + if (sourceInfo) { + return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); + } + if (isObjectLiteralType(source)) { + var related = -1 /* True */; + if (kind === 0 /* String */) { + var sourceNumberInfo = getIndexInfoOfType(source, 1 /* Number */); + if (sourceNumberInfo) { + related = indexInfoRelatedTo(sourceNumberInfo, targetInfo, reportErrors); + } + } + if (related) { + related &= eachPropertyRelatedTo(source, targetInfo.type, kind, reportErrors); + } + return related; + } + if (reportErrors) { + reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); + } + return 0 /* False */; + } + function indexTypesIdenticalTo(source, target, indexKind) { + var targetInfo = getIndexInfoOfType(target, indexKind); + var sourceInfo = getIndexInfoOfType(source, indexKind); + if (!sourceInfo && !targetInfo) { + return -1 /* True */; + } + if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) { + return isRelatedTo(sourceInfo.type, targetInfo.type); } return 0 /* False */; } @@ -19772,6 +20235,29 @@ var ts; } return -1 /* True */; } + function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { + if (!sourceSignature.declaration || !targetSignature.declaration) { + return true; + } + var sourceAccessibility = sourceSignature.declaration.flags & (8 /* Private */ | 16 /* Protected */); + var targetAccessibility = targetSignature.declaration.flags & (8 /* Private */ | 16 /* Protected */); + // A public, protected and private signature is assignable to a private signature. + if (targetAccessibility === 8 /* Private */) { + return true; + } + // A public and protected signature is assignable to a protected signature. + if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + return true; + } + // Only a public signature is assignable to public signature. + if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + return true; + } + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility)); + } + return false; + } } // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { @@ -19817,8 +20303,8 @@ var ts; if (sourceProp === targetProp) { return -1 /* True */; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 /* Private */ | 32 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 /* Private */ | 32 /* Protected */); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (8 /* Private */ | 16 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (8 /* Private */ | 16 /* Protected */); if (sourcePropAccessibility !== targetPropAccessibility) { return 0 /* False */; } @@ -19832,6 +20318,9 @@ var ts; return 0 /* False */; } } + if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { + return 0 /* False */; + } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { @@ -19941,8 +20430,10 @@ var ts; return type.flags & 4096 /* Reference */ && type.target === globalArrayType; } function isArrayLikeType(type) { - // A type is array-like if it is not the undefined or null type and if it is assignable to any[] - return !(type.flags & (32 /* Undefined */ | 64 /* Null */)) && isTypeAssignableTo(type, anyArrayType); + // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, + // or if it is not the undefined or null type and if it is assignable to ReadonlyArray + return type.flags & 4096 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || + !(type.flags & (32 /* Undefined */ | 64 /* Null */)) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isTupleLikeType(type) { return !!getPropertyOfType(type, "0"); @@ -19957,6 +20448,15 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192 /* Tuple */); } + /** + * Return true if type was inferred from an object literal or written as an object type literal + * with no call or construct signatures. + */ + function isObjectLiteralType(type) { + return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */)) !== 0 && + getSignaturesOfType(type, 0 /* Call */).length === 0 && + getSignaturesOfType(type, 1 /* Construct */).length === 0; + } function getRegularTypeOfObjectLiteral(type) { if (type.flags & 1048576 /* FreshObjectLiteral */) { var regularType = type.regularType; @@ -19967,8 +20467,8 @@ var ts; regularType.properties = type.properties; regularType.callSignatures = type.callSignatures; regularType.constructSignatures = type.constructSignatures; - regularType.stringIndexType = type.stringIndexType; - regularType.numberIndexType = type.numberIndexType; + regularType.stringIndexInfo = type.stringIndexInfo; + regularType.numberIndexInfo = type.numberIndexInfo; type.regularType = regularType; } return regularType; @@ -19993,22 +20493,15 @@ var ts; } members[p.name] = p; }); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndexInfo = getIndexInfoOfType(type, 0 /* String */); + var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); + return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); } function getWidenedType(type) { - if (type.flags & 140509184 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } - if (type.flags & 134217728 /* PredicateType */) { - return booleanType; - } if (type.flags & 524288 /* ObjectLiteral */) { return getWidenedTypeOfObjectLiteral(type); } @@ -20074,22 +20567,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 139 /* Parameter */: + case 140 /* 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 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -20156,6 +20649,7 @@ var ts; var targetStack; var depth = 0; var inferiority = 0; + var visited = {}; inferFromTypes(source, target); function isInProcess(source, target) { for (var i = 0; i < depth; i++) { @@ -20173,7 +20667,7 @@ var ts; // type, and for each such target constituent type infer from the type to itself. // When inferring from a type to itself we effectively find all type parameter // occurrences within that type and infer themselves as their type arguments. - var matchingTypes; + var matchingTypes = void 0; for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var t = _a[_i]; if (typeIdenticalToSomeType(t, source.types)) { @@ -20230,11 +20724,6 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (source.flags & 134217728 /* PredicateType */ && target.flags & 134217728 /* PredicateType */) { - if (source.predicate.kind === target.predicate.kind) { - inferFromTypes(source.predicate.type, target.predicate.type); - } - } 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; @@ -20246,7 +20735,7 @@ var ts; else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; - var typeParameter; + var typeParameter = void 0; // First infer to each type in union or intersection that isn't a type parameter for (var _b = 0, targetTypes_2 = targetTypes; _b < targetTypes_2.length; _b++) { var t = targetTypes_2[_b]; @@ -20269,7 +20758,7 @@ var ts; } } else if (source.flags & 49152 /* UnionOrIntersection */) { - // Source is a union or intersection type, infer from each consituent type + // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _c = 0, sourceTypes_3 = sourceTypes; _c < sourceTypes_3.length; _c++) { var sourceType = sourceTypes_3[_c]; @@ -20289,6 +20778,11 @@ var ts; if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { return; } + var key = source.id + "," + target.id; + if (ts.hasProperty(visited, key)) { + return; + } + visited[key] = true; if (depth === 0) { sourceStack = []; targetStack = []; @@ -20299,9 +20793,7 @@ var ts; inferFromProperties(source, target); inferFromSignatures(source, target, 0 /* Call */); inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); + inferFromIndexTypes(source, target); depth--; } } @@ -20328,14 +20820,29 @@ var ts; } function inferFromSignature(source, target) { forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (source.typePredicate && target.typePredicate && source.typePredicate.kind === target.typePredicate.kind) { + inferFromTypes(source.typePredicate.type, target.typePredicate.type); + } + else { + inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } } - function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); + function inferFromIndexTypes(source, target) { + var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); + if (targetStringIndexType) { + var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || + getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); + inferFromTypes(sourceIndexType, targetStringIndexType); + } + } + var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); + if (targetNumberIndexType) { + var sourceIndexType = getIndexTypeOfType(source, 1 /* Number */) || + getIndexTypeOfType(source, 0 /* String */) || + getImplicitIndexTypeOfType(source, 1 /* Number */); + if (sourceIndexType) { + inferFromTypes(sourceIndexType, targetNumberIndexType); } } } @@ -20426,10 +20933,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 155 /* TypeQuery */: + case 156 /* TypeQuery */: return true; case 69 /* Identifier */: - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: node = node.parent; continue; default: @@ -20471,55 +20978,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: - case 167 /* ArrayLiteralExpression */: - case 168 /* ObjectLiteralExpression */: - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 174 /* TypeAssertionExpression */: - case 192 /* AsExpression */: - case 175 /* ParenthesizedExpression */: - case 182 /* PrefixUnaryExpression */: - case 178 /* DeleteExpression */: - case 181 /* AwaitExpression */: - case 179 /* TypeOfExpression */: - case 180 /* VoidExpression */: - case 183 /* PostfixUnaryExpression */: - case 187 /* YieldExpression */: - case 185 /* ConditionalExpression */: - case 188 /* SpreadElementExpression */: - case 195 /* Block */: - case 196 /* VariableStatement */: - case 198 /* ExpressionStatement */: - case 199 /* IfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 207 /* ReturnStatement */: - case 208 /* WithStatement */: - case 209 /* SwitchStatement */: - case 244 /* CaseClause */: - case 245 /* DefaultClause */: - case 210 /* LabeledStatement */: - case 211 /* ThrowStatement */: - case 212 /* TryStatement */: - case 247 /* CatchClause */: - case 236 /* JsxElement */: - case 237 /* JsxSelfClosingElement */: - case 241 /* JsxAttribute */: - case 242 /* JsxSpreadAttribute */: - case 238 /* JsxOpeningElement */: - case 243 /* JsxExpression */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: + case 168 /* ArrayLiteralExpression */: + case 169 /* ObjectLiteralExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 175 /* TypeAssertionExpression */: + case 193 /* AsExpression */: + case 176 /* ParenthesizedExpression */: + case 183 /* PrefixUnaryExpression */: + case 179 /* DeleteExpression */: + case 182 /* AwaitExpression */: + case 180 /* TypeOfExpression */: + case 181 /* VoidExpression */: + case 184 /* PostfixUnaryExpression */: + case 188 /* YieldExpression */: + case 186 /* ConditionalExpression */: + case 189 /* SpreadElementExpression */: + case 196 /* Block */: + case 197 /* VariableStatement */: + case 199 /* ExpressionStatement */: + case 200 /* IfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 208 /* ReturnStatement */: + case 209 /* WithStatement */: + case 210 /* SwitchStatement */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: + case 211 /* LabeledStatement */: + case 212 /* ThrowStatement */: + case 213 /* TryStatement */: + case 248 /* CatchClause */: + case 237 /* JsxElement */: + case 238 /* JsxSelfClosingElement */: + case 242 /* JsxAttribute */: + case 243 /* JsxSpreadAttribute */: + case 239 /* JsxOpeningElement */: + case 244 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -20531,7 +21038,7 @@ var ts; // Only narrow when symbol is variable of type any or an object, union, or type parameter type if (node && symbol.flags & 3 /* Variable */) { if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { - var declaration = ts.getDeclarationOfKind(symbol, 214 /* VariableDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 215 /* VariableDeclaration */); var top_1 = declaration && getDeclarationContainer(declaration); var originalType = type; var nodeStack = []; @@ -20539,13 +21046,13 @@ var ts; var child = node; node = node.parent; switch (node.kind) { - case 199 /* IfStatement */: - case 185 /* ConditionalExpression */: - case 184 /* BinaryExpression */: + case 200 /* IfStatement */: + case 186 /* ConditionalExpression */: + case 185 /* BinaryExpression */: nodeStack.push({ node: node, child: child }); break; - case 251 /* SourceFile */: - case 221 /* ModuleDeclaration */: + case 252 /* SourceFile */: + case 222 /* ModuleDeclaration */: // Stop at the first containing file or module declaration break loop; } @@ -20553,23 +21060,23 @@ var ts; break; } } - var nodes; + var nodes = void 0; while (nodes = nodeStack.pop()) { var node_1 = nodes.node, child = nodes.child; switch (node_1.kind) { - case 199 /* IfStatement */: + case 200 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node_1.expression) { type = narrowType(type, node_1.expression, /*assumeTrue*/ child === node_1.thenStatement); } break; - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node_1.condition) { type = narrowType(type, node_1.condition, /*assumeTrue*/ child === node_1.whenTrue); } break; - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node_1.right) { if (node_1.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { @@ -20597,7 +21104,7 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 179 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { + if (expr.left.kind !== 180 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; @@ -20684,7 +21191,7 @@ var ts; } if (!targetType) { // Target type is type of construct signature - var constructSignatures; + var constructSignatures = void 0; if (rightType.flags & 2048 /* Interface */) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } @@ -20721,42 +21228,30 @@ var ts; } return originalType; } - function narrowTypeByTypePredicate(type, expr, assumeTrue) { + function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { if (type.flags & 1 /* Any */) { return type; } - var signature = getResolvedSignature(expr); - var predicateType = getReturnTypeOfSignature(signature); - if (!predicateType || !(predicateType.flags & 134217728 /* PredicateType */)) { + var signature = getResolvedSignature(callExpression); + var predicate = signature.typePredicate; + if (!predicate) { return type; } - var predicate = predicateType.predicate; if (ts.isIdentifierTypePredicate(predicate)) { - var callExpression = expr; if (callExpression.arguments[predicate.parameterIndex] && getSymbolAtTypePredicatePosition(callExpression.arguments[predicate.parameterIndex]) === symbol) { return getNarrowedType(type, predicate.type, assumeTrue); } } else { - var expression = skipParenthesizedNodes(expr.expression); - return narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue); + var invokedExpression = skipParenthesizedNodes(callExpression.expression); + return narrowTypeByThisTypePredicate(type, predicate, invokedExpression, assumeTrue); } return type; } - function narrowTypeByTypePredicateMember(type, expr, assumeTrue) { - if (type.flags & 1 /* Any */) { - return type; - } - var memberType = getTypeOfExpression(expr); - if (!(memberType.flags & 134217728 /* PredicateType */)) { - return type; - } - return narrowTypeByThisTypePredicate(type, memberType.predicate, expr, assumeTrue); - } - function narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue) { - if (expression.kind === 170 /* ElementAccessExpression */ || expression.kind === 169 /* PropertyAccessExpression */) { - var accessExpression = expression; + function narrowTypeByThisTypePredicate(type, predicate, invokedExpression, assumeTrue) { + if (invokedExpression.kind === 171 /* ElementAccessExpression */ || invokedExpression.kind === 170 /* PropertyAccessExpression */) { + var accessExpression = invokedExpression; var possibleIdentifier = skipParenthesizedNodes(accessExpression.expression); if (possibleIdentifier.kind === 69 /* Identifier */ && getSymbolAtTypePredicatePosition(possibleIdentifier) === symbol) { return getNarrowedType(type, predicate.type, assumeTrue); @@ -20768,8 +21263,7 @@ var ts; expr = skipParenthesizedNodes(expr); switch (expr.kind) { case 69 /* Identifier */: - case 169 /* PropertyAccessExpression */: - case 136 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: return getSymbolOfEntityNameOrPropertyAccessExpression(expr); } } @@ -20777,11 +21271,11 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 171 /* CallExpression */: + case 172 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: var operator = expr.operatorToken.kind; if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); @@ -20796,20 +21290,17 @@ var ts; return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: if (expr.operator === 49 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; - case 170 /* ElementAccessExpression */: - case 169 /* PropertyAccessExpression */: - return narrowTypeByTypePredicateMember(type, expr, assumeTrue); } return type; } } function skipParenthesizedNodes(expression) { - while (expression.kind === 175 /* ParenthesizedExpression */) { + while (expression.kind === 176 /* ParenthesizedExpression */) { expression = expression.expression; } return expression; @@ -20824,23 +21315,40 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 177 /* ArrowFunction */) { + if (container.kind === 178 /* 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); } } - if (node.parserContextFlags & 8 /* Await */) { - getNodeLinks(container).flags |= 4096 /* CaptureArguments */; - getNodeLinks(node).flags |= 2048 /* LexicalArguments */; + if (node.flags & 33554432 /* AwaitContext */) { + getNodeLinks(container).flags |= 8192 /* CaptureArguments */; } } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); } + var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); + // Due to the emit for class decorators, any reference to the class from inside of the class body + // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind + // behavior of class names in ES6. + if (languageVersion === 2 /* ES6 */ + && localOrExportSymbol.flags & 32 /* Class */ + && localOrExportSymbol.valueDeclaration.kind === 218 /* ClassDeclaration */ + && ts.nodeIsDecorated(localOrExportSymbol.valueDeclaration)) { + var container = ts.getContainingClass(node); + while (container !== undefined) { + if (container === localOrExportSymbol.valueDeclaration && container.name !== node) { + getNodeLinks(container).flags |= 524288 /* ClassWithBodyScopedClassBinding */; + getNodeLinks(node).flags |= 1048576 /* BodyScopedClassBinding */; + break; + } + container = ts.getContainingClass(container); + } + } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); - checkBlockScopedBindingCapturedInLoop(node, symbol); - return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); + checkNestedBlockScopedBinding(node, symbol); + return getNarrowedTypeOfSymbol(localOrExportSymbol, node); } function isInsideFunction(node, threshold) { var current = node; @@ -20852,52 +21360,79 @@ var ts; } return false; } - function checkBlockScopedBindingCapturedInLoop(node, symbol) { + function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 247 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 248 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check // if there is anything function like between declaration and use-site (is binding/class is captured in function). // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) - var container; - if (symbol.flags & 32 /* Class */) { - // get parent of class declaration - container = getClassLikeDeclarationOfSymbol(symbol).parent; - } - else { - // nesting structure: - // (variable declaration or binding element) -> variable declaration list -> container - container = symbol.valueDeclaration; - while (container.kind !== 215 /* VariableDeclarationList */) { - container = container.parent; - } - // get the parent of variable declaration list - container = container.parent; - if (container.kind === 196 /* VariableStatement */) { - // if parent is variable statement - get its parent - container = container.parent; - } - } - var inFunction = isInsideFunction(node.parent, container); + var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); + var usedInFunction = isInsideFunction(node.parent, container); var current = container; + var containedInIterationStatement = false; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - if (inFunction) { - getNodeLinks(current).flags |= 65536 /* LoopWithBlockScopedBindingCapturedInFunction */; - } - // mark value declaration so during emit they can have a special handling - getNodeLinks(symbol.valueDeclaration).flags |= 16384 /* BlockScopedBindingInLoop */; + containedInIterationStatement = true; break; } current = current.parent; } + if (containedInIterationStatement) { + if (usedInFunction) { + // mark iteration statement as containing block-scoped binding captured in some function + getNodeLinks(current).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + } + // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. + // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. + if (container.kind === 203 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 216 /* VariableDeclarationList */).parent === container && + isAssignedInBodyOfForStatement(node, container)) { + getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; + } + // set 'declared inside loop' bit on the block-scoped binding + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* BlockScopedBindingInLoop */; + } + if (usedInFunction) { + getNodeLinks(symbol.valueDeclaration).flags |= 131072 /* CapturedBlockScopedBinding */; + } + } + function isAssignedInBodyOfForStatement(node, container) { + var current = node; + // skip parenthesized nodes + while (current.parent.kind === 176 /* ParenthesizedExpression */) { + current = current.parent; + } + // check if node is used as LHS in some assignment expression + var isAssigned = false; + if (current.parent.kind === 185 /* BinaryExpression */) { + isAssigned = current.parent.left === current && ts.isAssignmentOperator(current.parent.operatorToken.kind); + } + if ((current.parent.kind === 183 /* PrefixUnaryExpression */ || current.parent.kind === 184 /* PostfixUnaryExpression */)) { + var expr = current.parent; + isAssigned = expr.operator === 41 /* PlusPlusToken */ || expr.operator === 42 /* MinusMinusToken */; + } + if (!isAssigned) { + return false; + } + // at this point we know that node is the target of assignment + // now check that modification happens inside the statement part of the ForStatement + while (current !== container) { + if (current === container.statement) { + return true; + } + else { + current = current.parent; + } + } + return false; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 142 /* PropertyDeclaration */ || container.kind === 145 /* Constructor */) { + if (container.kind === 143 /* PropertyDeclaration */ || container.kind === 146 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -20905,38 +21440,93 @@ var ts; getNodeLinks(container).flags |= 4 /* CaptureThis */; } } + function findFirstSuperCall(n) { + if (ts.isSuperCallExpression(n)) { + return n; + } + else if (ts.isFunctionLike(n)) { + return undefined; + } + return ts.forEachChild(n, findFirstSuperCall); + } + /** + * Return a cached result if super-statement is already found. + * Otherwise, find a super statement in a given constructor function and cache the result in the node-links of the constructor + * + * @param constructor constructor-function to look for super statement + */ + function getSuperCallInConstructor(constructor) { + var links = getNodeLinks(constructor); + // Only trying to find super-call if we haven't yet tried to find one. Once we try, we will record the result + if (links.hasSuperCall === undefined) { + links.superCall = findFirstSuperCall(constructor.body); + links.hasSuperCall = links.superCall ? true : false; + } + return links.superCall; + } + /** + * Check if the given class-declaration extends null then return true. + * Otherwise, return false + * @param classDecl a class declaration to check if it extends null + */ + function classDeclarationExtendsNull(classDecl) { + var classSymbol = getSymbolOfNode(classDecl); + var classInstanceType = getDeclaredTypeOfSymbol(classSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType); + return baseConstructorType === nullType; + } 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, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; + if (container.kind === 146 /* Constructor */) { + var containingClassDecl = container.parent; + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + // If a containing class does not have extends clause or the class extends null + // skip checking whether super statement is called before "this" accessing. + if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { + var superCall = getSuperCallInConstructor(container); + // We should give an error in the following cases: + // - No super-call + // - "this" is accessing before super-call. + // i.e super(this) + // this.x; super(); + // We want to make sure that super-call is done before accessing "this" so that + // "this" is not accessed as a parameter of the super-call. + if (!superCall || superCall.end > node.pos) { + // In ES6, super inside constructor of class-declaration has to precede "this" accessing + error(node, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); + } + } + } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 177 /* ArrowFunction */) { + if (container.kind === 178 /* 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 221 /* ModuleDeclaration */: + case 222 /* 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 220 /* EnumDeclaration */: + case 221 /* 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 145 /* Constructor */: + case 146 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - if (container.flags & 64 /* Static */) { + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + if (container.flags & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -20945,40 +21535,55 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 64 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 32 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } - // If this is a function in a JS file, it might be a class method. Check if it's the RHS - // of a x.prototype.y = function [name]() { .... } - if (ts.isInJavaScriptFile(node) && container.kind === 176 /* FunctionExpression */) { - if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { - // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') - var className = container.parent // x.protoype.y = f - .left // x.prototype.y - .expression // x.prototype - .expression; // x - var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - return getInferredClassType(classSymbol); + if (ts.isInJavaScriptFile(node)) { + var type = getTypeForThisExpressionFromJSDoc(container); + if (type && type !== unknownType) { + return type; + } + // If this is a function in a JS file, it might be a class method. Check if it's the RHS + // of a x.prototype.y = function [name]() { .... } + if (container.kind === 177 /* FunctionExpression */) { + if (ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { + // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') + var className = container.parent // x.prototype.y = f + .left // x.prototype.y + .expression // x.prototype + .expression; // x + var classSymbol = checkExpression(className).symbol; + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + return getInferredClassType(classSymbol); + } } } } return anyType; } + function getTypeForThisExpressionFromJSDoc(node) { + var typeTag = ts.getJSDocTypeTag(node); + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 265 /* JSDocFunctionType */) { + var jsDocFunctionType = typeTag.typeExpression.type; + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 268 /* JSDocThisType */) { + return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); + } + } + } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 139 /* Parameter */) { + if (n.kind === 140 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 171 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 172 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; if (!isCallExpression) { // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting - while (container && container.kind === 177 /* ArrowFunction */) { + while (container && container.kind === 178 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } @@ -20992,16 +21597,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 137 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 138 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 137 /* ComputedPropertyName */) { + if (current && current.kind === 138 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 168 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 169 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -21009,20 +21614,84 @@ var ts; } return unknownType; } - if ((container.flags & 64 /* Static */) || isCallExpression) { + if ((container.flags & 32 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; } else { nodeCheckFlag = 256 /* SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; + // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. + // This is due to the fact that we emit the body of an async function inside of a generator function. As generator + // functions cannot reference `super`, we emit a helper inside of the method body, but outside of the generator. This helper + // uses an arrow function, which is permitted to reference `super`. + // + // There are two primary ways we can access `super` from within an async method. The first is getting the value of a property + // or indexed access on super, either as part of a right-hand-side expression or call expression. The second is when setting the value + // of a property or indexed access, either as part of an assignment expression or destructuring assignment. + // + // The simplest case is reading a value, in which case we will emit something like the following: + // + // // ts + // ... + // async asyncMethod() { + // let x = await super.asyncMethod(); + // return x; + // } + // ... + // + // // js + // ... + // asyncMethod() { + // const _super = name => super[name]; + // return __awaiter(this, arguments, Promise, function *() { + // let x = yield _super("asyncMethod").call(this); + // return x; + // }); + // } + // ... + // + // The more complex case is when we wish to assign a value, especially as part of a destructuring assignment. As both cases + // are legal in ES6, but also likely less frequent, we emit the same more complex helper for both scenarios: + // + // // ts + // ... + // async asyncMethod(ar: Promise) { + // [super.a, super.b] = await ar; + // } + // ... + // + // // js + // ... + // asyncMethod(ar) { + // const _super = (function (geti, seti) { + // const cache = Object.create(null); + // return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } }); + // })(name => super[name], (name, value) => super[name] = value); + // return __awaiter(this, arguments, Promise, function *() { + // [_super("a").value, _super("b").value] = yield ar; + // }); + // } + // ... + // + // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. + // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment + // while a property access can. + if (container.kind === 145 /* MethodDeclaration */ && container.flags & 256 /* Async */) { + if (ts.isSuperPropertyOrElementAccess(node.parent) && isAssignmentTarget(node.parent)) { + getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + } + else { + getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + } + } 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 (container.parent.kind === 168 /* ObjectLiteralExpression */) { + if (container.parent.kind === 169 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -21042,7 +21711,7 @@ var ts; } return unknownType; } - if (container.kind === 145 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 146 /* 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; @@ -21057,7 +21726,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 145 /* Constructor */; + return container.kind === 146 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -21065,21 +21734,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 168 /* ObjectLiteralExpression */) { - if (container.flags & 64 /* Static */) { - return container.kind === 144 /* MethodDeclaration */ || - container.kind === 143 /* MethodSignature */ || - container.kind === 146 /* GetAccessor */ || - container.kind === 147 /* SetAccessor */; + if (ts.isClassLike(container.parent) || container.parent.kind === 169 /* ObjectLiteralExpression */) { + if (container.flags & 32 /* Static */) { + return container.kind === 145 /* MethodDeclaration */ || + container.kind === 144 /* MethodSignature */ || + container.kind === 147 /* GetAccessor */ || + container.kind === 148 /* SetAccessor */; } else { - return container.kind === 144 /* MethodDeclaration */ || - container.kind === 143 /* MethodSignature */ || - container.kind === 146 /* GetAccessor */ || - container.kind === 147 /* SetAccessor */ || - container.kind === 142 /* PropertyDeclaration */ || - container.kind === 141 /* PropertySignature */ || - container.kind === 145 /* Constructor */; + return container.kind === 145 /* MethodDeclaration */ || + container.kind === 144 /* MethodSignature */ || + container.kind === 147 /* GetAccessor */ || + container.kind === 148 /* SetAccessor */ || + container.kind === 143 /* PropertyDeclaration */ || + container.kind === 142 /* PropertySignature */ || + container.kind === 146 /* Constructor */; } } } @@ -21121,7 +21790,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 139 /* Parameter */) { + if (declaration.kind === 140 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -21154,7 +21823,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 139 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 140 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -21165,8 +21834,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 === 145 /* Constructor */ || - functionDecl.kind === 146 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 147 /* SetAccessor */))) { + functionDecl.kind === 146 /* Constructor */ || + functionDecl.kind === 147 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 148 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -21188,7 +21857,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 173 /* TaggedTemplateExpression */) { + if (template.parent.kind === 174 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -21261,10 +21930,6 @@ var ts; function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } - // Return true if the given contextual type provides an index signature of the given kind - function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); - } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one // exists. Otherwise, it is the type of the string index signature in T, if one exists. @@ -21319,13 +21984,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 241 /* JsxAttribute */) { + if (attribute.kind === 242 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 242 /* JsxSpreadAttribute */) { + else if (attribute.kind === 243 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -21345,7 +22010,7 @@ var ts; * Otherwise this may not be very useful. * * In cases where you *are* working on this function, you should understand - * when it is appropriate to use 'getContextualType' and 'getApparentTypeOfContetxualType'. + * when it is appropriate to use 'getContextualType' and 'getApparentTypeOfContextualType'. * * - Use 'getContextualType' when you are simply going to propagate the result to the expression. * - Use 'getApparentTypeOfContextualType' when you're going to need the members of the type. @@ -21363,40 +22028,40 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 214 /* VariableDeclaration */: - case 139 /* Parameter */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 140 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 167 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 177 /* ArrowFunction */: - case 207 /* ReturnStatement */: + case 178 /* ArrowFunction */: + case 208 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 174 /* TypeAssertionExpression */: - case 192 /* AsExpression */: + case 175 /* TypeAssertionExpression */: + case 193 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 248 /* PropertyAssignment */: + case 249 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 193 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 186 /* TemplateExpression */); + case 194 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 187 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return getContextualType(parent); - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: return getContextualType(parent); - case 241 /* JsxAttribute */: - case 242 /* JsxSpreadAttribute */: + case 242 /* JsxAttribute */: + case 243 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -21413,7 +22078,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 176 /* FunctionExpression */ || node.kind === 177 /* ArrowFunction */; + return node.kind === 177 /* FunctionExpression */ || node.kind === 178 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -21427,7 +22092,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 !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getApparentTypeOfContextualType(node); @@ -21490,13 +22155,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 184 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 185 /* BinaryExpression */ && parent.operatorToken.kind === 56 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 248 /* PropertyAssignment */) { + if (parent.kind === 249 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 167 /* ArrayLiteralExpression */) { + if (parent.kind === 168 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -21512,8 +22177,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 166 /* BindingElement */ && !!node.initializer) || - (node.kind === 184 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + return (node.kind === 167 /* BindingElement */ && !!node.initializer) || + (node.kind === 185 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -21522,7 +22187,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 188 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 189 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -21546,7 +22211,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 188 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 189 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -21561,7 +22226,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 165 /* ArrayBindingPattern */ || pattern.kind === 167 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 166 /* ArrayBindingPattern */ || pattern.kind === 168 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -21569,7 +22234,7 @@ var ts; elementTypes.push(contextualType.elementTypes[i]); } else { - if (patternElement.kind !== 190 /* OmittedExpression */) { + if (patternElement.kind !== 191 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -21584,7 +22249,7 @@ var ts; return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 137 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 138 /* 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, @@ -21592,7 +22257,7 @@ var ts; return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132 /* NumberLike */); } function isTypeAnyOrAllConstituentTypesHaveKind(type, kind) { - return isTypeAny(type) || allConstituentTypesHaveKind(type, kind); + return isTypeAny(type) || isTypeOfKind(type, kind); } function isNumericLiteralName(name) { // The intent of numeric names is that @@ -21633,6 +22298,16 @@ var ts; } return links.resolvedType; } + function getObjectLiteralIndexInfo(node, properties, kind) { + var propTypes = []; + for (var i = 0; i < properties.length; i++) { + if (kind === 0 /* String */ || isNumericName(node.properties[i].name)) { + propTypes.push(getTypeOfSymbol(properties[i])); + } + } + var unionType = propTypes.length ? getUnionType(propTypes) : undefinedType; + return createIndexInfo(unionType, /*isReadonly*/ false); + } function checkObjectLiteral(node, contextualMapper) { var inDestructuringPattern = isAssignmentTarget(node); // Grammar checking @@ -21641,24 +22316,26 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 164 /* ObjectBindingPattern */ || contextualType.pattern.kind === 168 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 165 /* ObjectBindingPattern */ || contextualType.pattern.kind === 169 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; + var hasComputedStringProperty = false; + var hasComputedNumberProperty = false; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 248 /* PropertyAssignment */ || - memberDecl.kind === 249 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 249 /* PropertyAssignment */ || + memberDecl.kind === 250 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 248 /* PropertyAssignment */) { + if (memberDecl.kind === 249 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 144 /* MethodDeclaration */) { + else if (memberDecl.kind === 145 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 249 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 250 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -21666,8 +22343,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 248 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 249 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 249 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 250 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -21701,10 +22378,18 @@ 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 === 146 /* GetAccessor */ || memberDecl.kind === 147 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 147 /* GetAccessor */ || memberDecl.kind === 148 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } - if (!ts.hasDynamicName(memberDecl)) { + if (ts.hasDynamicName(memberDecl)) { + if (isNumericName(memberDecl.name)) { + hasComputedNumberProperty = true; + } + else { + hasComputedStringProperty = true; + } + } + else { propertiesTable[member.name] = member; } propertiesArray.push(member); @@ -21723,37 +22408,15 @@ var ts; } } } - var stringIndexType = getIndexType(0 /* String */); - var numberIndexType = getIndexType(1 /* Number */); - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0 /* String */) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1 /* Number */) : undefined; + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */) | (patternWithComputedProperties ? 67108864 /* ObjectLiteralPatternWithComputedProperties */ : 0); if (inDestructuringPattern) { result.pattern = node; } return result; - function getIndexType(kind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - var propTypes = []; - for (var i = 0; i < propertiesArray.length; i++) { - var propertyDecl = node.properties[i]; - if (kind === 0 /* String */ || isNumericName(propertyDecl.name)) { - // Do not call getSymbolOfNode(propertyDecl), as that will get the - // original symbol for the node. We actually want to get the symbol - // created by checkObjectLiteral, since that will be appropriately - // contextually typed and resolved. - var type = getTypeOfSymbol(propertiesArray[i]); - if (!ts.contains(propTypes, type)) { - propTypes.push(type); - } - } - } - var result_1 = propTypes.length ? getUnionType(propTypes) : undefinedType; - typeFlags |= result_1.flags; - return result_1; - } - return undefined; - } } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -21763,18 +22426,18 @@ var ts; // Check attributes checkJsxOpeningLikeElement(node.openingElement); // Perform resolution on the closing tag so that rename/go to definition/etc work - getJsxElementTagSymbol(node.closingElement); + getJsxTagSymbol(node.closingElement); // Check children for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: checkJsxExpression(child); break; - case 236 /* JsxElement */: + case 237 /* JsxElement */: checkJsxElement(child); break; - case 237 /* JsxSelfClosingElement */: + case 238 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -21792,7 +22455,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 === 136 /* QualifiedName */) { + if (tagName.kind === 137 /* QualifiedName */) { return false; } else { @@ -21862,70 +22525,49 @@ var ts; } return jsxTypes[name]; } - /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if - /// this is an intrinsic tag. This might be a named - /// property of the IntrinsicElements interface, or its string indexer. - /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class - /// type or factory function. - /// Otherwise, returns unknownSymbol. - function getJsxElementTagSymbol(node) { + function getJsxTagSymbol(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return getIntrinsicTagSymbol(node); + } + else { + return checkExpression(node.tagName).symbol; + } + } + /** + * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic + * property (in which case nodeLinks.jsxFlags will be IntrinsicNamedElement) or an intrinsic + * string index signature (in which case nodeLinks.jsxFlags will be IntrinsicIndexedElement). + * May also return unknownSymbol if both of these lookups fail. + */ + function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - links.resolvedSymbol = lookupIntrinsicTag(node); - } - else { - links.resolvedSymbol = lookupClassTag(node); - } - } - return links.resolvedSymbol; - function lookupIntrinsicTag(node) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { // Property case var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); if (intrinsicProp) { links.jsxFlags |= 1 /* IntrinsicNamedElement */; - return intrinsicProp; + return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); if (indexSignatureType) { links.jsxFlags |= 2 /* IntrinsicIndexedElement */; - return intrinsicElementsType.symbol; + return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); - return unknownSymbol; + return links.resolvedSymbol = unknownSymbol; } else { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } - return unknownSymbol; - } - } - function lookupClassTag(node) { - var valueSymbol = resolveJsxTagName(node); - // Look up the value in the current scope - if (valueSymbol && valueSymbol !== unknownSymbol) { - links.jsxFlags |= 4 /* ValueElement */; - if (valueSymbol.flags & 8388608 /* Alias */) { - markAliasSymbolAsReferenced(valueSymbol); - } - } - return valueSymbol || unknownSymbol; - } - function resolveJsxTagName(node) { - if (node.tagName.kind === 69 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - return sym.exportSymbol || sym; - } - else { - return checkQualifiedName(node.tagName).symbol; + return links.resolvedSymbol = unknownSymbol; } } + return links.resolvedSymbol; } /** * Given a JSX element that is a class element, finds the Element Instance Type. If the @@ -21933,15 +22575,7 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node) { - // 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 /* ValueElement */), "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 - return anyType; - } - var valueType = getTypeOfSymbol(classSymbol); + var valueType = checkExpression(node.tagName); if (isTypeAny(valueType)) { // Short-circuit if the class tag is using an element type 'any' return anyType; @@ -21960,10 +22594,10 @@ var ts; return getUnionType(signatures.map(getReturnTypeOfSignature)); } /// e.g. "props" for React.d.ts, - /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), /// or '' if it has 0 properties (which means every - /// non-instrinsic elements' attributes type is the element instance type) + /// non-intrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); @@ -21971,7 +22605,7 @@ var ts; var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); // JSX.ElementAttributesProperty [type] var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - // The properites of JSX.ElementAttributesProperty + // The properties of JSX.ElementAttributesProperty var attribProperties = attribPropType && getPropertiesOfType(attribPropType); if (attribProperties) { // Element Attributes has zero properties, so the element attributes type will be the class instance type @@ -21998,15 +22632,23 @@ var ts; function getJsxElementAttributesType(node) { var links = getNodeLinks(node); if (!links.resolvedJsxType) { - var sym = getJsxElementTagSymbol(node); - if (links.jsxFlags & 4 /* ValueElement */) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var symbol = getIntrinsicTagSymbol(node); + if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxType = getTypeOfSymbol(symbol); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; + } + } + else { // Get the element instance type (the result of newing or invoking this tag) var elemInstanceType = getJsxElementInstanceType(node); var elemClassType = getJsxGlobalElementClassType(); if (!elemClassType || !isTypeAssignableTo(elemInstanceType, elemClassType)) { // Is this is a stateless function component? See if its single signature's return type is // assignable to the JSX Element Type - var elemType = getTypeOfSymbol(sym); + var elemType = checkExpression(node.tagName); var callSignatures = elemType && getSignaturesOfType(elemType, 0 /* Call */); var callSignature = callSignatures && callSignatures.length > 0 && callSignatures[0]; var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); @@ -22074,16 +22716,7 @@ var ts; } } } - else if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxType = getTypeOfSymbol(sym); - } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { - return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0 /* String */); - } - else { - // Resolution failed, so we don't know - return links.resolvedJsxType = anyType; - } + return links.resolvedJsxType = unknownType; } return links.resolvedJsxType; } @@ -22137,11 +22770,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 === 241 /* JsxAttribute */) { + if (node.attributes[i].kind === 242 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 242 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 243 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -22171,10 +22804,10 @@ 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 : 142 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 143 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 8 /* Public */ | 64 /* Static */ : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; } /** * Check whether the requested property access is valid. @@ -22186,9 +22819,9 @@ var ts; */ function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); if (left.kind === 95 /* SuperKeyword */) { - var errorNode = node.kind === 169 /* PropertyAccessExpression */ ? + var errorNode = node.kind === 170 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -22198,7 +22831,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 144 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 145 /* 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); @@ -22214,7 +22847,7 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & (16 /* Private */ | 32 /* Protected */))) { + if (!(flags & (8 /* Private */ | 16 /* Protected */))) { return true; } // Property is known to be private or protected at this point @@ -22222,7 +22855,7 @@ var ts; var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; // Private property is accessible if declaring and enclosing class are the same - if (flags & 16 /* Private */) { + if (flags & 8 /* Private */) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -22240,7 +22873,7 @@ var ts; return false; } // No further restrictions for static properties - if (flags & 64 /* Static */) { + if (flags & 32 /* Static */) { return true; } // An instance property must be accessed through an instance of the enclosing class @@ -22285,7 +22918,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 169 /* PropertyAccessExpression */ + var left = node.kind === 170 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -22302,7 +22935,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 215 /* VariableDeclarationList */) { + if (initializer.kind === 216 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -22331,7 +22964,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 203 /* ForInStatement */ && + if (node.kind === 204 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -22348,7 +22981,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 172 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 173 /* 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); @@ -22398,15 +23031,17 @@ var ts; if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { - var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); - if (numberIndexType) { - return numberIndexType; + var numberIndexInfo = getIndexInfoOfType(objectType, 1 /* Number */); + if (numberIndexInfo) { + getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; + return numberIndexInfo.type; } } // Try to use string indexing. - var stringIndexType = getIndexTypeOfType(objectType, 0 /* String */); - if (stringIndexType) { - return stringIndexType; + var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); + if (stringIndexInfo) { + getNodeLinks(node).resolvedIndexInfo = stringIndexInfo; + return stringIndexInfo.type; } // Fall back to any. if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { @@ -22431,7 +23066,7 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 170 /* ElementAccessExpression */ || indexArgumentExpression.kind === 169 /* PropertyAccessExpression */) { + if (indexArgumentExpression.kind === 171 /* ElementAccessExpression */ || indexArgumentExpression.kind === 170 /* PropertyAccessExpression */) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -22486,10 +23121,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 173 /* TaggedTemplateExpression */) { + if (node.kind === 174 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 140 /* Decorator */) { + else if (node.kind !== 141 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -22519,13 +23154,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_5 = signature.declaration && signature.declaration.parent; + var parent_6 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_5 === lastParent) { + if (lastParent && parent_6 === lastParent) { index++; } else { - lastParent = parent_5; + lastParent = parent_6; index = cutoffIndex; } } @@ -22533,7 +23168,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_5; + lastParent = parent_6; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -22555,7 +23190,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 188 /* SpreadElementExpression */) { + if (arg && arg.kind === 189 /* SpreadElementExpression */) { return i; } } @@ -22567,13 +23202,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 === 173 /* TaggedTemplateExpression */) { + if (node.kind === 174 /* 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 === 186 /* TemplateExpression */) { + if (tagExpression.template.kind === 187 /* 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; @@ -22590,7 +23225,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 140 /* Decorator */) { + else if (node.kind === 141 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -22599,7 +23234,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 172 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 173 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -22634,7 +23269,7 @@ var ts; if (type.flags & 80896 /* ObjectType */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && - resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { + resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { return resolved.callSignatures[0]; } } @@ -22678,7 +23313,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 !== 190 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 191 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -22699,7 +23334,7 @@ var ts; // Tagged template expressions will always have `undefined` for `excludeArgument[0]`. if (excludeArgument) { for (var i = 0; i < argCount; i++) { - // No need to check for omitted args and template expressions, their exlusion value is always undefined + // No need to check for omitted args and template expressions, their exclusion value is always undefined if (excludeArgument[i] === false) { var arg = args[i]; var paramType = getTypeAtPosition(signature, i); @@ -22738,7 +23373,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 !== 190 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 191 /* 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); @@ -22770,16 +23405,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 173 /* TaggedTemplateExpression */) { + if (node.kind === 174 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 186 /* TemplateExpression */) { + if (template.kind === 187 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 140 /* Decorator */) { + else if (node.kind === 141 /* 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. @@ -22804,19 +23439,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 140 /* Decorator */) { + if (node.kind === 141 /* Decorator */) { switch (node.parent.kind) { - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If we are emitting decorators for ES3, we will only pass two arguments. @@ -22826,7 +23461,7 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 139 /* Parameter */: + case 140 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -22850,25 +23485,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 139 /* Parameter */) { + if (node.kind === 140 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 145 /* Constructor */) { + if (node.kind === 146 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 142 /* PropertyDeclaration */ || - node.kind === 144 /* MethodDeclaration */ || - node.kind === 146 /* GetAccessor */ || - node.kind === 147 /* SetAccessor */) { + if (node.kind === 143 /* PropertyDeclaration */ || + node.kind === 145 /* MethodDeclaration */ || + node.kind === 147 /* GetAccessor */ || + node.kind === 148 /* 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 @@ -22895,21 +23530,21 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 139 /* Parameter */) { + if (node.kind === 140 /* Parameter */) { node = node.parent; - if (node.kind === 145 /* Constructor */) { + if (node.kind === 146 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 142 /* PropertyDeclaration */ || - node.kind === 144 /* MethodDeclaration */ || - node.kind === 146 /* GetAccessor */ || - node.kind === 147 /* SetAccessor */) { + if (node.kind === 143 /* PropertyDeclaration */ || + node.kind === 145 /* MethodDeclaration */ || + node.kind === 147 /* GetAccessor */ || + node.kind === 148 /* 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 @@ -22920,9 +23555,9 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getStringLiteralTypeForText(element.name.text); - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { + if (isTypeOfKind(nameType, 16777216 /* ESSymbol */)) { return nameType; } else { @@ -22945,22 +23580,22 @@ var ts; */ function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator - // or its `parameterIndex` for a paramter decorator - if (node.kind === 217 /* ClassDeclaration */) { + // or its `parameterIndex` for a parameter decorator + if (node.kind === 218 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 139 /* Parameter */) { + if (node.kind === 140 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 142 /* PropertyDeclaration */) { + if (node.kind === 143 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 144 /* MethodDeclaration */ || - node.kind === 146 /* GetAccessor */ || - node.kind === 147 /* SetAccessor */) { + if (node.kind === 145 /* MethodDeclaration */ || + node.kind === 147 /* GetAccessor */ || + node.kind === 148 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -22992,10 +23627,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 === 140 /* Decorator */) { + if (node.kind === 141 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 174 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -23007,8 +23642,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 === 140 /* Decorator */ || - (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */)) { + if (node.kind === 141 /* Decorator */ || + (argIndex === 0 && node.kind === 174 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -23017,11 +23652,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 140 /* Decorator */) { + if (node.kind === 141 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 173 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 174 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -23030,8 +23665,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 173 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 140 /* Decorator */; + var isTaggedTemplate = node.kind === 174 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 141 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -23137,8 +23772,8 @@ var ts; } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - var typeArguments_1 = node.typeArguments; - checkTypeArguments(candidateForTypeArgumentError, typeArguments_1, ts.map(typeArguments_1, getTypeFromTypeNode), /*reportErrors*/ true, headMessage); + var typeArguments_2 = node.typeArguments; + checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNode), /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -23250,8 +23885,10 @@ var ts; // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); - return resolveCall(node, baseConstructors, candidatesOutArray); + if (baseTypeNode) { + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + return resolveCall(node, baseConstructors, candidatesOutArray); + } } return resolveUntypedCall(node); } @@ -23275,7 +23912,7 @@ var ts; // We exclude union types because we may have a union of function types that happen to have // no common signatures. if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { - // The unknownType indicates that an error already occured (and was reported). No + // The unknownType indicates that an error already occurred (and was reported). No // need to report another error in this case. if (funcType !== unknownType && node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -23338,6 +23975,9 @@ var ts; // that the user will not add any. var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); if (constructSignatures.length) { + if (!isConstructorAccessible(node, constructSignatures[0])) { + return resolveErrorCall(node); + } return resolveCall(node, constructSignatures, candidatesOutArray); } // If expressionType's apparent type is an object type with no construct signatures but @@ -23355,6 +23995,30 @@ var ts; error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); return resolveErrorCall(node); } + function isConstructorAccessible(node, signature) { + if (!signature || !signature.declaration) { + return true; + } + var declaration = signature.declaration; + var flags = declaration.flags; + // Public constructor is accessible. + if (!(flags & (8 /* Private */ | 16 /* Protected */))) { + return true; + } + var declaringClassDeclaration = getClassLikeDeclarationOfSymbol(declaration.parent.symbol); + var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol); + // A private or protected constructor can only be instantiated within it's own class + if (!isNodeWithinClass(node, declaringClassDeclaration)) { + if (flags & 8 /* Private */) { + error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); + } + if (flags & 16 /* Protected */) { + error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); + } + return false; + } + return true; + } function resolveTaggedTemplateExpression(node, candidatesOutArray) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); @@ -23377,16 +24041,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 139 /* Parameter */: + case 140 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -23405,7 +24069,7 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorInfo; + var errorInfo = void 0; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); @@ -23423,16 +24087,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 171 /* CallExpression */) { + if (node.kind === 172 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 172 /* NewExpression */) { + else if (node.kind === 173 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 173 /* TaggedTemplateExpression */) { + else if (node.kind === 174 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 140 /* Decorator */) { + else if (node.kind === 141 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -23460,12 +24124,13 @@ var ts; if (node.expression.kind === 95 /* SuperKeyword */) { return voidType; } - if (node.kind === 172 /* NewExpression */) { + if (node.kind === 173 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 145 /* Constructor */ && - declaration.kind !== 149 /* ConstructSignature */ && - declaration.kind !== 154 /* ConstructorType */) { + declaration.kind !== 146 /* Constructor */ && + declaration.kind !== 150 /* ConstructSignature */ && + declaration.kind !== 155 /* ConstructorType */ && + !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations // in a JS file @@ -23480,7 +24145,7 @@ var ts; } } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node)) { + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -23494,8 +24159,8 @@ var ts; if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); // Permit 'number[] | "foo"' to be asserted to 'string'. - var bothAreStringLike = someConstituentTypeHasKind(targetType, 258 /* StringLike */) && - someConstituentTypeHasKind(widenedType, 258 /* StringLike */); + var bothAreStringLike = maybeTypeOfKind(targetType, 258 /* StringLike */) && + maybeTypeOfKind(widenedType, 258 /* StringLike */); if (!bothAreStringLike && !(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); } @@ -23526,7 +24191,7 @@ var ts; if (ts.isBindingPattern(node.name)) { for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 190 /* OmittedExpression */) { + if (element.kind !== 191 /* OmittedExpression */) { if (element.name.kind === 69 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } @@ -23574,6 +24239,13 @@ var ts; inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } + function getReturnTypeFromJSDocComment(func) { + var returnTag = ts.getJSDocReturnTag(func); + if (returnTag && returnTag.typeExpression) { + return getTypeFromTypeNode(returnTag.typeExpression.type); + } + return undefined; + } function createPromiseType(promisedType) { // creates a `Promise` type where `T` is the promisedType argument var globalPromiseType = getGlobalPromiseType(); @@ -23591,7 +24263,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 195 /* Block */) { + if (func.body.kind !== 196 /* 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 @@ -23602,7 +24274,7 @@ var ts; } } else { - var types; + var types = void 0; var funcIsGenerator = !!func.asteriskToken; if (funcIsGenerator) { types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper); @@ -23641,7 +24313,8 @@ var ts; } else { error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; + // Defer to unioning the return types so we get a) downstream errors earlier and b) better Salsa experience + return getUnionType(types); } } if (funcIsGenerator) { @@ -23704,11 +24377,13 @@ var ts; }); return aggregatedTypes; } - /* - *TypeScript Specification 1.0 (6.3) - July 2014 - * An explicitly typed function whose return type isn't the Void or the Any type - * must have at least one return statement somewhere in its body. - * An exception to this rule is if the function implementation consists of a single 'throw' statement. + /** + * TypeScript Specification 1.0 (6.3) - July 2014 + * An explicitly typed function whose return type isn't the Void type, + * the Any type, or a union type containing the Void or Any type as a constituent + * must have at least one return statement somewhere in its body. + * An exception to this rule is if the function implementation consists of a single 'throw' statement. + * * @param returnType - return type of the function, can be undefined if return type is not explicitly specified */ function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { @@ -23716,15 +24391,15 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType === voidType || isTypeAny(returnType)) { + if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 16 /* Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 195 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 196 /* Block */ || !(func.flags & 32768 /* HasImplicitReturn */)) { return; } - var hasExplicitReturn = func.flags & 1048576 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 65536 /* HasExplicitReturn */; if (returnType && !hasExplicitReturn) { // minimal check: function has syntactic return type annotation and no explicit return statements in the body // this function does not conform to the specification. @@ -23747,10 +24422,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 176 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 177 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -23790,14 +24465,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 144 /* MethodDeclaration */ && node.kind !== 143 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 145 /* MethodDeclaration */ && node.kind !== 144 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 144 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 145 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -23813,7 +24488,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 195 /* Block */) { + if (node.body.kind === 196 /* Block */) { checkSourceElement(node.body); } else { @@ -23842,75 +24517,74 @@ var ts; } return true; } - function checkReferenceExpression(n, invalidReferenceMessage, constantVariableMessage) { - function findSymbol(n) { - var symbol = getNodeLinks(n).resolvedSymbol; - // Because we got the symbol from the resolvedSymbol property, it might be of kind - // SymbolFlags.ExportValue. In this case it is necessary to get the actual export - // symbol, which will have the correct flags set on it. - return symbol && getExportSymbolOfValueSymbolIfExported(symbol); + function isReadonlySymbol(symbol) { + // The following symbols are considered read-only: + // Properties with a 'readonly' modifier + // Variables declared with 'const' + // Get accessors without matching set accessors + // Enum members + return symbol.flags & 4 /* Property */ && (getDeclarationFlagsFromSymbol(symbol) & 64 /* Readonly */) !== 0 || + symbol.flags & 3 /* Variable */ && (getDeclarationFlagsFromSymbol(symbol) & 2048 /* Const */) !== 0 || + symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || + (symbol.flags & 8 /* EnumMember */) !== 0; + } + function isReferenceToReadonlyEntity(expr, symbol) { + if (isReadonlySymbol(symbol)) { + // Allow assignments to readonly properties within constructors of the same class declaration. + if (symbol.flags & 4 /* Property */ && + (expr.kind === 170 /* PropertyAccessExpression */ || expr.kind === 171 /* ElementAccessExpression */) && + expr.expression.kind === 97 /* ThisKeyword */) { + var func = ts.getContainingFunction(expr); + return !(func && func.kind === 146 /* Constructor */ && func.parent === symbol.valueDeclaration.parent); + } + return true; } - function isReferenceOrErrorExpression(n) { - // TypeScript 1.0 spec (April 2014): - // Expressions are classified as values or references. - // References are the subset of expressions that are permitted as the target of an assignment. - // Specifically, references are combinations of identifiers(section 4.3), parentheses(section 4.7), - // and property accesses(section 4.10). - // All other expression constructs described in this chapter are classified as values. - switch (n.kind) { - case 69 /* 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; + return false; + } + function isReferenceThroughNamespaceImport(expr) { + if (expr.kind === 170 /* PropertyAccessExpression */ || expr.kind === 171 /* ElementAccessExpression */) { + var node = skipParenthesizedNodes(expr.expression); + if (node.kind === 69 /* Identifier */) { + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol.flags & 8388608 /* Alias */) { + var declaration = getDeclarationOfAliasSymbol(symbol); + return declaration && declaration.kind === 228 /* NamespaceImport */; } - case 169 /* PropertyAccessExpression */: { - var symbol = findSymbol(n); - // TypeScript 1.0 spec (April 2014): 4.10 - // A property access expression is always classified as a reference. - // NOTE (not in spec): assignment to enum members should not be allowed - return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - } - case 170 /* ElementAccessExpression */: - // old compiler doesn't check indexed access - return true; - case 175 /* ParenthesizedExpression */: - return isReferenceOrErrorExpression(n.expression); - default: - return false; } } - function isConstVariableReference(n) { - switch (n.kind) { - case 69 /* Identifier */: - case 169 /* PropertyAccessExpression */: { - var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384 /* Const */) !== 0; - } - case 170 /* ElementAccessExpression */: { - var index = n.argumentExpression; - var symbol = findSymbol(n.expression); - 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) & 16384 /* Const */) !== 0; - } + return false; + } + function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { + // References are combinations of identifiers, parentheses, and property accesses. + var node = skipParenthesizedNodes(expr); + if (node.kind !== 69 /* Identifier */ && node.kind !== 170 /* PropertyAccessExpression */ && node.kind !== 171 /* ElementAccessExpression */) { + error(expr, invalidReferenceMessage); + return false; + } + // Because we get the symbol from the resolvedSymbol property, it might be of kind + // SymbolFlags.ExportValue. In this case it is necessary to get the actual export + // symbol, which will have the correct flags set on it. + var links = getNodeLinks(node); + var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); + if (symbol) { + if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { + // Only variables (and not functions, classes, namespaces, enum objects, or enum members) + // are considered references when referenced using a simple identifier. + if (node.kind === 69 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { + error(expr, invalidReferenceMessage); return false; } - case 175 /* ParenthesizedExpression */: - return isConstVariableReference(n.expression); - default: + if (isReferenceToReadonlyEntity(node, symbol) || isReferenceThroughNamespaceImport(node)) { + error(expr, constantVariableMessage); return false; + } } } - if (!isReferenceOrErrorExpression(n)) { - error(n, invalidReferenceMessage); - return false; - } - if (isConstVariableReference(n)) { - error(n, constantVariableMessage); - return false; + else if (node.kind === 171 /* ElementAccessExpression */) { + if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { + error(expr, constantVariableMessage); + return false; + } } return true; } @@ -23929,7 +24603,7 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.parserContextFlags & 8 /* Await */)) { + if (!(node.flags & 33554432 /* AwaitContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -23945,7 +24619,7 @@ var ts; case 35 /* PlusToken */: case 36 /* MinusToken */: case 50 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { + if (maybeTypeOfKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; @@ -23956,7 +24630,7 @@ var ts; 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 - 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } @@ -23967,43 +24641,53 @@ var ts; 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 - 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } - // Just like isTypeOfKind below, except that it returns true if *any* constituent - // has this kind. - function someConstituentTypeHasKind(type, kind) { + // Return true if type might be of the given kind. A union or intersection type might be of a given + // kind if at least one constituent type is of the given kind. + function maybeTypeOfKind(type, kind) { if (type.flags & kind) { return true; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var current = types_10[_i]; - if (current.flags & kind) { + var t = types_10[_i]; + if (maybeTypeOfKind(t, kind)) { return true; } } - return false; } return false; } - // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. - function allConstituentTypesHaveKind(type, kind) { + // Return true if type is of the given kind. A union type is of a given kind if all constituent types + // are of the given kind. An intersection type is of a given kind if at least one constituent type is + // of the given kind. + function isTypeOfKind(type, kind) { if (type.flags & kind) { return true; } - if (type.flags & 49152 /* UnionOrIntersection */) { + if (type.flags & 16384 /* Union */) { var types = type.types; for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var current = types_11[_i]; - if (!(current.flags & kind)) { + var t = types_11[_i]; + if (!isTypeOfKind(t, kind)) { return false; } } return true; } + if (type.flags & 32768 /* Intersection */) { + var types = type.types; + for (var _a = 0, types_12 = types; _a < types_12.length; _a++) { + var t = types_12[_a]; + if (isTypeOfKind(t, kind)) { + return true; + } + } + } return false; } function isConstEnumObjectType(type) { @@ -24018,7 +24702,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, 16777726 /* Primitive */)) { + if (isTypeOfKind(leftType, 16777726 /* Primitive */)) { error(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 @@ -24044,22 +24728,22 @@ var ts; var properties = node.properties; for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var p = properties_3[_i]; - if (p.kind === 248 /* PropertyAssignment */ || p.kind === 249 /* ShorthandPropertyAssignment */) { - var name_13 = p.name; - if (name_13.kind === 137 /* ComputedPropertyName */) { - checkComputedPropertyName(name_13); + if (p.kind === 249 /* PropertyAssignment */ || p.kind === 250 /* ShorthandPropertyAssignment */) { + var name_12 = p.name; + if (name_12.kind === 138 /* ComputedPropertyName */) { + checkComputedPropertyName(name_12); } - if (isComputedNonLiteralName(name_13)) { + if (isComputedNonLiteralName(name_12)) { continue; } - var text = getTextOfPropertyName(name_13); + var text = getTextOfPropertyName(name_12); var type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, text) || isNumericLiteralName(text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - if (p.kind === 249 /* ShorthandPropertyAssignment */) { + if (p.kind === 250 /* ShorthandPropertyAssignment */) { checkDestructuringAssignment(p, type); } else { @@ -24068,7 +24752,7 @@ var ts; } } else { - error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); + error(name_12, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_12)); } } else { @@ -24085,8 +24769,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 190 /* OmittedExpression */) { - if (e.kind !== 188 /* SpreadElementExpression */) { + if (e.kind !== 191 /* OmittedExpression */) { + if (e.kind !== 189 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -24111,7 +24795,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 184 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + if (restExpression.kind === 185 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -24125,7 +24809,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 249 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 250 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); @@ -24135,21 +24819,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 184 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + if (target.kind === 185 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 168 /* ObjectLiteralExpression */) { + if (target.kind === 169 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 167 /* ArrayLiteralExpression */) { + if (target.kind === 168 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) { checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; @@ -24159,7 +24843,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 168 /* ObjectLiteralExpression */ || left.kind === 167 /* ArrayLiteralExpression */)) { + if (operator === 56 /* EqualsToken */ && (left.kind === 169 /* ObjectLiteralExpression */ || left.kind === 168 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -24197,7 +24881,7 @@ var ts; leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) rightType = leftType; - var suggestedOperator; + var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion if ((leftType.flags & 8 /* Boolean */) && @@ -24224,14 +24908,14 @@ var ts; leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) rightType = leftType; - var resultType; - if (allConstituentTypesHaveKind(leftType, 132 /* NumberLike */) && allConstituentTypesHaveKind(rightType, 132 /* NumberLike */)) { + var resultType = void 0; + if (isTypeOfKind(leftType, 132 /* NumberLike */) && isTypeOfKind(rightType, 132 /* NumberLike */)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } else { - if (allConstituentTypesHaveKind(leftType, 258 /* StringLike */) || allConstituentTypesHaveKind(rightType, 258 /* StringLike */)) { + if (isTypeOfKind(leftType, 258 /* StringLike */) || isTypeOfKind(rightType, 258 /* StringLike */)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -24266,7 +24950,7 @@ var ts; case 32 /* EqualsEqualsEqualsToken */: case 33 /* ExclamationEqualsEqualsToken */: // Permit 'number[] | "foo"' to be asserted to 'string'. - if (someConstituentTypeHasKind(leftType, 258 /* StringLike */) && someConstituentTypeHasKind(rightType, 258 /* StringLike */)) { + if (maybeTypeOfKind(leftType, 258 /* StringLike */) && maybeTypeOfKind(rightType, 258 /* StringLike */)) { return booleanType; } if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { @@ -24289,8 +24973,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? left : - someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 16777216 /* ESSymbol */) ? left : + maybeTypeOfKind(rightType, 16777216 /* ESSymbol */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -24321,7 +25005,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported @@ -24351,7 +25035,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.parserContextFlags & 2 /* Yield */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8388608 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -24364,7 +25048,7 @@ var ts; // we are in a yield context. if (func && func.asteriskToken) { var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); - var expressionElementType; + var expressionElementType = void 0; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); @@ -24428,7 +25112,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 === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -24439,7 +25123,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 === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -24469,7 +25153,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 136 /* QualifiedName */) { + if (node.kind === 137 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -24481,9 +25165,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 170 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 171 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 69 /* Identifier */ || node.kind === 137 /* 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); } @@ -24510,7 +25194,7 @@ var ts; return booleanType; case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: return checkTemplateExpression(node); case 9 /* StringLiteral */: return checkStringLiteralExpression(node); @@ -24518,58 +25202,58 @@ var ts; return stringType; case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 169 /* PropertyAccessExpression */: + case 170 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 170 /* ElementAccessExpression */: + case 171 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return checkCallExpression(node); - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: return checkClassExpression(node); - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 179 /* TypeOfExpression */: + case 180 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 174 /* TypeAssertionExpression */: - case 192 /* AsExpression */: + case 175 /* TypeAssertionExpression */: + case 193 /* AsExpression */: return checkAssertion(node); - case 178 /* DeleteExpression */: + case 179 /* DeleteExpression */: return checkDeleteExpression(node); - case 180 /* VoidExpression */: + case 181 /* VoidExpression */: return checkVoidExpression(node); - case 181 /* AwaitExpression */: + case 182 /* AwaitExpression */: return checkAwaitExpression(node); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 183 /* PostfixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 188 /* SpreadElementExpression */: + case 189 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 190 /* OmittedExpression */: + case 191 /* OmittedExpression */: return undefinedType; - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: return checkYieldExpression(node); - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: return checkJsxExpression(node); - case 236 /* JsxElement */: + case 237 /* JsxElement */: return checkJsxElement(node); - case 237 /* JsxSelfClosingElement */: + case 238 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 238 /* JsxOpeningElement */: + case 239 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -24595,9 +25279,9 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 56 /* AccessibilityModifier */) { + if (node.flags & 28 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 145 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 146 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -24614,9 +25298,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 144 /* MethodDeclaration */ || - node.kind === 216 /* FunctionDeclaration */ || - node.kind === 176 /* FunctionExpression */; + return node.kind === 145 /* MethodDeclaration */ || + node.kind === 217 /* FunctionDeclaration */ || + node.kind === 177 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -24633,18 +25317,19 @@ var ts; function checkTypePredicate(node) { var parent = getTypePredicateParent(node); if (!parent) { + // The parent must not be valid. + error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; } - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(parent)); - if (!returnType || !(returnType.flags & 134217728 /* PredicateType */)) { + var typePredicate = getSignatureFromDeclaration(parent).typePredicate; + if (!typePredicate) { return; } var parameterName = node.parameterName; - if (parameterName.kind === 162 /* ThisType */) { + if (ts.isThisTypePredicate(typePredicate)) { getTypeFromThisTypeNode(parameterName); } else { - var typePredicate = returnType.predicate; if (typePredicate.parameterIndex >= 0) { if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); @@ -24656,10 +25341,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_14 = _a[_i].name; - if ((name_14.kind === 164 /* ObjectBindingPattern */ || - name_14.kind === 165 /* ArrayBindingPattern */) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, parameterName, typePredicate.parameterName)) { + var name_13 = _a[_i].name; + if (ts.isBindingPattern(name_13) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_13, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -24672,30 +25356,30 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 177 /* ArrowFunction */: - case 148 /* CallSignature */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 153 /* FunctionType */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - var parent_6 = node.parent; - if (node === parent_6.type) { - return parent_6; + case 178 /* ArrowFunction */: + case 149 /* CallSignature */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 154 /* FunctionType */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + var parent_7 = node.parent; + if (node === parent_7.type) { + return parent_7; } } } function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { - var name_15 = _a[_i].name; - if (name_15.kind === 69 /* Identifier */ && - name_15.text === predicateVariableName) { + var name_14 = _a[_i].name; + if (name_14.kind === 69 /* Identifier */ && + name_14.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_15.kind === 165 /* ArrayBindingPattern */ || - name_15.kind === 164 /* ObjectBindingPattern */) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_15, predicateVariableNode, predicateVariableName)) { + else if (name_14.kind === 166 /* ArrayBindingPattern */ || + name_14.kind === 165 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_14, predicateVariableNode, predicateVariableName)) { return true; } } @@ -24703,25 +25387,27 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 150 /* IndexSignature */) { + if (node.kind === 151 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 153 /* FunctionType */ || node.kind === 216 /* FunctionDeclaration */ || node.kind === 154 /* ConstructorType */ || - node.kind === 148 /* CallSignature */ || node.kind === 145 /* Constructor */ || - node.kind === 149 /* ConstructSignature */) { + else if (node.kind === 154 /* FunctionType */ || node.kind === 217 /* FunctionDeclaration */ || node.kind === 155 /* ConstructorType */ || + node.kind === 149 /* CallSignature */ || node.kind === 146 /* Constructor */ || + node.kind === 150 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); - checkSourceElement(node.type); + if (node.type) { + checkSourceElement(node.type); + } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 148 /* CallSignature */: + case 149 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -24744,12 +25430,14 @@ var ts; checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } + else if (ts.isAsyncFunctionLike(node)) { + checkAsyncFunctionReturnType(node); + } } } - checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 218 /* InterfaceDeclaration */) { + if (node.kind === 219 /* 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 @@ -24769,7 +25457,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 130 /* StringKeyword */: + case 131 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -24777,7 +25465,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 128 /* NumberKeyword */: + case 129 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -24809,7 +25497,7 @@ var ts; function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. checkSignatureDeclaration(node); - // Grammar check for checking only related to constructoDeclaration + // Grammar check for checking only related to constructorDeclaration checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); var symbol = getSymbolOfNode(node); @@ -24825,14 +25513,11 @@ var ts; if (!produceDiagnostics) { return; } - function isSuperCallExpression(n) { - return n.kind === 171 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; - } function containsSuperCallAsComputedPropertyName(n) { return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { - if (isSuperCallExpression(n)) { + if (ts.isSuperCallExpression(n)) { return true; } else if (ts.isFunctionLike(n)) { @@ -24847,13 +25532,13 @@ var ts; if (n.kind === 97 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 176 /* FunctionExpression */ && n.kind !== 216 /* FunctionDeclaration */) { + else if (n.kind !== 177 /* FunctionExpression */ && n.kind !== 217 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 142 /* PropertyDeclaration */ && - !(n.flags & 64 /* Static */) && + return n.kind === 143 /* PropertyDeclaration */ && + !(n.flags & 32 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 @@ -24861,12 +25546,11 @@ var ts; // constructors of derived classes must contain at least one super call somewhere in their function body. 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 classExtendsNull = classDeclarationExtendsNull(containingClassDecl); + var superCall = getSuperCallInConstructor(node); + if (superCall) { + if (classExtendsNull) { + error(superCall, 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: @@ -24874,15 +25558,15 @@ var ts; // - 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 & (8 /* Public */ | 16 /* Private */ | 32 /* Protected */); }); + ts.forEach(node.parameters, function (p) { return p.flags & (4 /* Public */ | 8 /* Private */ | 16 /* 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; - var superCallStatement; + var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 198 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + if (statement.kind === 199 /* ExpressionStatement */ && ts.isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; } @@ -24893,13 +25577,9 @@ var ts; 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(superCallStatement.expression); - } } } - else if (baseConstructorType !== nullType) { + else if (!classExtendsNull) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -24910,9 +25590,9 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 146 /* GetAccessor */) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288 /* HasImplicitReturn */)) { - if (node.flags & 1048576 /* HasExplicitReturn */) { + if (node.kind === 147 /* GetAccessor */) { + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 32768 /* HasImplicitReturn */)) { + if (node.flags & 65536 /* HasExplicitReturn */) { if (compilerOptions.noImplicitReturns) { error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -24925,18 +25605,21 @@ 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 === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 146 /* GetAccessor */ ? 147 /* SetAccessor */ : 146 /* GetAccessor */; + var otherKind = node.kind === 147 /* GetAccessor */ ? 148 /* SetAccessor */ : 147 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 56 /* AccessibilityModifier */) !== (otherAccessor.flags & 56 /* AccessibilityModifier */))) { + if (((node.flags & 28 /* AccessibilityModifier */) !== (otherAccessor.flags & 28 /* AccessibilityModifier */))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } + if (((node.flags & 128 /* Abstract */) !== (otherAccessor.flags & 128 /* Abstract */))) { + error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + } var currentAccessorType = getAnnotatedAccessorType(node); var otherAccessorType = getAnnotatedAccessorType(otherAccessor); // TypeScript 1.0 spec (April 2014): 4.5 @@ -24950,7 +25633,7 @@ var ts; } getTypeOfAccessors(getSymbolOfNode(node)); } - if (node.parent.kind !== 168 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 169 /* ObjectLiteralExpression */) { checkSourceElement(node.body); } else { @@ -25019,59 +25702,21 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 16 /* Private */) && ts.isInAmbientContext(node); - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { - if (!produceDiagnostics) { - return; - } - var signature = getSignatureFromDeclaration(signatureDeclarationNode); - if (!signature.hasStringLiterals) { - return; - } - // TypeScript 1.0 spec (April 2014): 3.7.2.2 - // Specialized signatures are not permitted in conjunction with a function body - if (ts.nodeIsPresent(signatureDeclarationNode.body)) { - error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); - return; - } - // TypeScript 1.0 spec (April 2014): 3.7.2.4 - // Every specialized call or construct signature in an object type must be assignable - // to at least one non-specialized call or construct signature in the same object type - 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 === 218 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 148 /* CallSignature */ || signatureDeclarationNode.kind === 149 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 148 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; - var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - var containingType = getDeclaredTypeOfSymbol(containingSymbol); - signaturesToCheck = getSignaturesOfType(containingType, signatureKind); - } - else { - signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); - } - for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { - var otherSignature = signaturesToCheck_1[_i]; - if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature, /*ignoreReturnTypes*/ false)) { - return; - } - } - error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); + return (node.flags & 8 /* Private */) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 218 /* InterfaceDeclaration */ && - n.parent.kind !== 217 /* ClassDeclaration */ && - n.parent.kind !== 189 /* ClassExpression */ && + if (n.parent.kind !== 219 /* InterfaceDeclaration */ && + n.parent.kind !== 218 /* ClassDeclaration */ && + n.parent.kind !== 190 /* ClassExpression */ && ts.isInAmbientContext(n)) { - if (!(flags & 4 /* Ambient */)) { + if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported - flags |= 2 /* Export */; + flags |= 1 /* Export */; } - flags |= 4 /* Ambient */; + flags |= 2 /* Ambient */; } return flags & flagsToCheck; } @@ -25093,36 +25738,36 @@ var ts; // deviations, we XOR someOverloadFlags with allOverloadFlags var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; if (someButNotAllOverloadFlags !== 0) { - var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); + var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { - var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 2 /* Export */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); + var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; + if (deviation & 1 /* Export */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 4 /* Ambient */) { + else if (deviation & 2 /* Ambient */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (16 /* Private */ | 32 /* Protected */)) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); + else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + error(o.name || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } else if (deviation & 128 /* Abstract */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); } } function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { if (someHaveQuestionToken !== allHaveQuestionToken) { - var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); + var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); ts.forEach(overloads, function (o) { - var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; + var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1; if (deviation) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); } }); } } - var flagsToCheck = 2 /* Export */ | 4 /* Ambient */ | 16 /* Private */ | 32 /* Protected */ | 128 /* Abstract */; + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -25146,21 +25791,21 @@ var ts; seen = c === node; } }); - // We may be here because of some extra junk between overloads that could not be parsed into a valid node. + // We may be here because of some extra nodes between overloads that could not be parsed into a valid node. // In this case the subsequent node is not really consecutive (.pos !== node.end), and we must ignore it here. if (subsequentNode && subsequentNode.pos === node.end) { if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) && - (node.flags & 64 /* Static */) !== (subsequentNode.flags & 64 /* Static */); + var reportError = (node.kind === 145 /* MethodDeclaration */ || node.kind === 144 /* MethodSignature */) && + (node.flags & 32 /* Static */) !== (subsequentNode.flags & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members // 2. something with the same name was defined before the set of overloads that prevents them from merging // here we'll report error only for the first case since for second we should already report error in binder if (reportError) { - var diagnostic = node.flags & 64 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + var diagnostic = node.flags & 32 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); } return; @@ -25195,7 +25840,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 218 /* InterfaceDeclaration */ || node.parent.kind === 156 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 219 /* InterfaceDeclaration */ || node.parent.kind === 157 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -25206,7 +25851,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 === 216 /* FunctionDeclaration */ || node.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */ || node.kind === 145 /* Constructor */) { + if (node.kind === 217 /* FunctionDeclaration */ || node.kind === 145 /* MethodDeclaration */ || node.kind === 144 /* MethodSignature */ || node.kind === 146 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -25258,29 +25903,11 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - // If the implementation signature has string literals, we will have reported an error in - // checkSpecializedSignatureDeclaration - if (!bodySignature.hasStringLiterals) { - // TypeScript 1.0 spec (April 2014): 6.1 - // If a function declaration includes overloads, the overloads determine the call - // signatures of the type given to the function object - // and the function implementation signature must be assignable to that type - // - // TypeScript 1.0 spec (April 2014): 3.8.4 - // Note that specialized call and construct signatures (section 3.7.2.4) are not significant when determining assignment compatibility - // Consider checking against specialized signatures too. Not doing so creates a type hole: - // - // function g(x: "hi", y: boolean); - // function g(x: string, y: {}); - // function g(x: string, y: string) { } - // - // The implementation is completely unrelated to the specialized signature, yet we do not check this. - for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { - var signature = signatures_3[_a]; - if (!signature.hasStringLiterals && !isImplementationCompatibleWithOverload(bodySignature, signature)) { - error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); - break; - } + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; + if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { + error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); + break; } } } @@ -25313,8 +25940,8 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 2 /* Export */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { if (effectiveDeclarationFlags & 512 /* Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } @@ -25326,7 +25953,7 @@ var ts; nonExportedDeclarationSpaces |= declarationSpaces; } } - // Spaces for anyting not declared a 'default export'. + // Spaces for anything not declared a 'default export'. var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; @@ -25335,7 +25962,7 @@ var ts; 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. + // Only error on the declarations that contributed 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)); } @@ -25346,20 +25973,20 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 224 /* ImportEqualsDeclaration */: - var result = 0; + case 225 /* ImportEqualsDeclaration */: + var result_1 = 0; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); - return result; + ts.forEach(target.declarations, function (d) { result_1 |= getDeclarationSpaces(d); }); + return result_1; default: return 1048576 /* ExportValue */; } @@ -25516,6 +26143,33 @@ var ts; } } } + /** + * Checks that the return type provided is an instantiation of the global Promise type + * and returns the awaited type of the return type. + * + * @param returnType The return type of a FunctionLikeDeclaration + * @param location The node on which to report the error. + */ + function checkCorrectPromiseType(returnType, location) { + if (returnType === unknownType) { + // The return type already had some other error, so we ignore and return + // the unknown type. + return unknownType; + } + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType === emptyGenericType + || globalPromiseType === getTargetType(returnType)) { + // Either we couldn't resolve the global promise type, which would have already + // reported an error, or we could resolve it and the return type is a valid type + // reference to the global type. In either case, we return the awaited type for + // the return type. + return checkAwaitedType(returnType, location, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } + // The promise type was not a valid type reference to the global promise type, so we + // report an error and return the unknown type. + error(location, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + return unknownType; + } /** * Checks the return type of an async function to ensure it is a compatible * Promise implementation. @@ -25530,6 +26184,10 @@ var ts; * callable `then` signature. */ function checkAsyncFunctionReturnType(node) { + if (languageVersion >= 2 /* ES6 */) { + var returnType = getTypeFromTypeNode(node.type); + return checkCorrectPromiseType(returnType, node.type); + } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify @@ -25605,22 +26263,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 139 /* Parameter */: + case 140 /* 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 142 /* PropertyDeclaration */: + case 143 /* 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 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -25633,9 +26291,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 152 /* TypeReference */) { + if (node && node.kind === 153 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 152 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = root.parent.kind === 153 /* 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 @@ -25677,25 +26335,25 @@ var ts; return; } if (!compilerOptions.experimentalDecorators) { - error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); + error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } if (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 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 142 /* PropertyDeclaration */: - case 139 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 140 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } @@ -25708,6 +26366,7 @@ var ts; checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function checkFunctionOrMethodDeclaration(node) { @@ -25717,7 +26376,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 === 137 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 138 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -25768,7 +26427,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 195 /* Block */) { + if (node.kind === 196 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -25788,12 +26447,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 142 /* PropertyDeclaration */ || - node.kind === 141 /* PropertySignature */ || - node.kind === 144 /* MethodDeclaration */ || - node.kind === 143 /* MethodSignature */ || - node.kind === 146 /* GetAccessor */ || - node.kind === 147 /* SetAccessor */) { + if (node.kind === 143 /* PropertyDeclaration */ || + node.kind === 142 /* PropertySignature */ || + node.kind === 145 /* MethodDeclaration */ || + node.kind === 144 /* MethodSignature */ || + node.kind === 147 /* GetAccessor */ || + node.kind === 148 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -25802,7 +26461,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 139 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 140 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -25855,16 +26514,31 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 221 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 222 /* 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 === 251 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 252 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } + function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { + if (!needCollisionCheckForIdentifier(node, name, "Promise")) { + return; + } + // Uninstantiated modules shouldnt do this check + if (node.kind === 222 /* 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 === 252 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2097152 /* HasAsyncFunctions */) { + // If the declaration happens to be in external module, report error that Promise is a reserved identifier. + error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); + } + } function checkVarDeclaredNamesNotShadowed(node) { // - ScriptBody : StatementList // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList @@ -25889,13 +26563,13 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3072 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // 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 === 214 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 215 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -25904,25 +26578,25 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 215 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 196 /* VariableStatement */ && varDeclList.parent.parent + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 3072 /* BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 216 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 197 /* 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 === 195 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 222 /* ModuleBlock */ || - container.kind === 221 /* ModuleDeclaration */ || - container.kind === 251 /* SourceFile */); + (container.kind === 196 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 223 /* ModuleBlock */ || + container.kind === 222 /* ModuleDeclaration */ || + container.kind === 252 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail // since LHS will be block scoped name instead of function scoped if (!namesShareScope) { - var name_16 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_16, name_16); + 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); } } } @@ -25930,7 +26604,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 139 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 140 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -25941,7 +26615,7 @@ var ts; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 139 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 140 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -25967,15 +26641,15 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 137 /* ComputedPropertyName */) { + if (node.name.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 166 /* BindingElement */) { + if (node.kind === 167 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 137 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 138 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } } @@ -25984,14 +26658,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 === 139 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 140 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 203 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 204 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -26002,7 +26676,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 203 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 204 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -26018,15 +26692,16 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 142 /* PropertyDeclaration */ && node.kind !== 141 /* PropertySignature */) { + if (node.kind !== 143 /* PropertyDeclaration */ && node.kind !== 142 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 214 /* VariableDeclaration */ || node.kind === 166 /* BindingElement */) { + if (node.kind === 215 /* VariableDeclaration */ || node.kind === 167 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } function checkVariableDeclaration(node) { @@ -26044,7 +26719,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 === 168 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 169 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -26065,7 +26740,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 197 /* EmptyStatement */) { + if (node.thenStatement.kind === 198 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -26085,12 +26760,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 216 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -26110,14 +26785,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 === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* 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 === 167 /* ArrayLiteralExpression */ || varExpr.kind === 168 /* ObjectLiteralExpression */) { + if (varExpr.kind === 168 /* ArrayLiteralExpression */ || varExpr.kind === 169 /* 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. @@ -26126,7 +26801,7 @@ var ts; else { var leftType = checkExpression(varExpr); checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, - /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); // 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 @@ -26146,7 +26821,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 === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* 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); @@ -26160,7 +26835,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 === 167 /* ArrayLiteralExpression */ || varExpr.kind === 168 /* ObjectLiteralExpression */) { + if (varExpr.kind === 168 /* ArrayLiteralExpression */ || varExpr.kind === 169 /* 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 */)) { @@ -26168,7 +26843,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); + checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); } } var rightType = checkExpression(node.expression); @@ -26339,7 +27014,7 @@ var ts; * This function does the following steps: * 1. Break up arrayOrStringType (possibly a union) into its string constituents and array constituents. * 2. Take the element types of the array constituents. - * 3. Return the union of the element types, and string if there was a string constitutent. + * 3. Return the union of the element types, and string if there was a string constituent. * * For example: * string -> string @@ -26404,8 +27079,8 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); // TODO: Check that target label is valid } - function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 146 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 147 /* SetAccessor */))); + function isGetAccessorWithAnnotatedSetAccessor(node) { + return !!(node.kind === 147 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 148 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -26428,15 +27103,15 @@ var ts; // for generators. return; } - if (func.kind === 147 /* SetAccessor */) { + if (func.kind === 148 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 145 /* Constructor */) { + else if (func.kind === 146 /* Constructor */) { if (!checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || returnType.flags & 134217728 /* PredicateType */) { + else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { if (ts.isAsyncFunctionLike(func)) { var promisedType = getPromisedType(returnType); var awaitedType = checkAwaitedType(exprType, node.expression, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -26457,7 +27132,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.parserContextFlags & 8 /* Await */) { + if (node.flags & 33554432 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -26470,10 +27145,10 @@ var ts; var firstDefaultClause; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); - var expressionTypeIsStringLike = someConstituentTypeHasKind(expressionType, 258 /* StringLike */); + var expressionTypeIsStringLike = maybeTypeOfKind(expressionType, 258 /* StringLike */); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 245 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 246 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -26485,14 +27160,14 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 244 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 245 /* 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); var expressionTypeIsAssignableToCaseType = // Permit 'number[] | "foo"' to be asserted to 'string'. - (expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, 258 /* StringLike */)) || + (expressionTypeIsStringLike && maybeTypeOfKind(caseType, 258 /* StringLike */)) || isTypeAssignableTo(expressionType, caseType); if (!expressionTypeIsAssignableToCaseType) { // 'expressionType is not assignable to caseType', try the reversed check and report errors if it fails @@ -26510,7 +27185,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 210 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 211 /* 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; @@ -26584,7 +27259,7 @@ var ts; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!(member.flags & 64 /* Static */) && ts.hasDynamicName(member)) { + if (!(member.flags & 32 /* Static */) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); @@ -26615,7 +27290,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 === 137 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 138 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -26649,7 +27324,7 @@ var ts; error(name, message, name.text); } } - // Check each type parameter and check that list has no duplicate type parameter declarations + /** Check each type parameter and check that type parameters have no duplicate type parameter declarations */ function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { for (var i = 0, n = typeParameterDeclarations.length; i < n; i++) { @@ -26665,6 +27340,24 @@ var ts; } } } + /** Check that type parameter lists are identical across multiple declarations */ + function checkTypeParameterListsIdentical(node, symbol) { + if (symbol.declarations.length === 1) { + return; + } + var firstDecl; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 218 /* ClassDeclaration */ || declaration.kind === 219 /* InterfaceDeclaration */) { + if (!firstDecl) { + firstDecl = declaration; + } + else if (!areTypeParametersIdentical(firstDecl.typeParameters, node.typeParameters)) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); + } + } + } + } function checkClassExpression(node) { checkClassLikeDeclaration(node); checkNodeDeferred(node); @@ -26687,6 +27380,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } checkTypeParameters(node.typeParameters); checkExportsOnMergedDeclarations(node); @@ -26694,12 +27388,14 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); var staticType = getTypeOfSymbol(symbol); + checkTypeParameterListsIdentical(node, symbol); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { - var baseType = baseTypes[0]; + var baseType_1 = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); @@ -26710,7 +27406,7 @@ var ts; } } } - checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify @@ -26718,11 +27414,11 @@ var ts; // references (as opposed to checking the structure of the types) because elsewhere we have already checked // that the base type is a class or interface type (and not, for example, an anonymous object type). var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); - if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType; })) { + if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } - checkKindsOfPropertyMemberOverrides(type, baseType); + checkKindsOfPropertyMemberOverrides(type, baseType_1); } } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); @@ -26752,6 +27448,18 @@ var ts; checkTypeForDuplicateIndexSignatures(node); } } + function checkBaseTypeAccessibility(type, node) { + var signatures = getSignaturesOfType(type, 1 /* Construct */); + if (signatures.length) { + var declaration = signatures[0].declaration; + if (declaration && declaration.flags & 8 /* Private */) { + var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); + if (!isNodeWithinClass(node, typeClassDeclaration)) { + error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, node.expression.text); + } + } + } + } function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags @@ -26786,7 +27494,7 @@ var ts; var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { - // In order to resolve whether the inherited method was overriden in the base class or not, + // In order to resolve whether the inherited method was overridden in the base class or not, // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { @@ -26796,7 +27504,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 189 /* ClassExpression */) { + if (derivedClassDecl.kind === 190 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -26807,11 +27515,11 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 16 /* Private */) || (derivedDeclarationFlags & 16 /* Private */)) { + if ((baseDeclarationFlags & 8 /* Private */) || (derivedDeclarationFlags & 8 /* Private */)) { // either base or derived property is private - not override, skip it continue; } - if ((baseDeclarationFlags & 64 /* Static */) !== (derivedDeclarationFlags & 64 /* Static */)) { + if ((baseDeclarationFlags & 32 /* Static */) !== (derivedDeclarationFlags & 32 /* Static */)) { // value of 'static' is not the same for properties - not override, skip it continue; } @@ -26844,7 +27552,7 @@ var ts; } } function isAccessor(kind) { - return kind === 146 /* GetAccessor */ || kind === 147 /* SetAccessor */; + return kind === 147 /* GetAccessor */ || kind === 148 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -26914,13 +27622,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 218 /* InterfaceDeclaration */); - if (symbol.declarations.length > 1) { - if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); - } - } + checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 219 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -26953,7 +27657,7 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { + if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; // set to undefined when enum member is non-constant @@ -26992,7 +27696,7 @@ var ts; autoValue++; } } - nodeLinks.flags |= 8192 /* EnumValuesComputed */; + nodeLinks.flags |= 16384 /* EnumValuesComputed */; } function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { // Controls if error should be reported after evaluation of constant value is completed @@ -27024,7 +27728,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -27035,7 +27739,7 @@ var ts; case 50 /* TildeToken */: return ~value_1; } return undefined; - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -27060,15 +27764,15 @@ var ts; return undefined; case 8 /* NumericLiteral */: return +e.text; - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return evalConstant(e.expression); case 69 /* Identifier */: - case 170 /* ElementAccessExpression */: - case 169 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 170 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; - var propertyName; + var propertyName = void 0; if (e.kind === 69 /* 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 @@ -27076,8 +27780,8 @@ var ts; propertyName = e.text; } else { - var expression; - if (e.kind === 170 /* ElementAccessExpression */) { + var expression = void 0; + if (e.kind === 171 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -27095,7 +27799,7 @@ var ts; if (current.kind === 69 /* Identifier */) { break; } - else if (current.kind === 169 /* PropertyAccessExpression */) { + else if (current.kind === 170 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -27140,6 +27844,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); var enumIsConst = ts.isConst(node); @@ -27163,10 +27868,10 @@ var ts; } }); } - var seenEnumMissingInitialInitializer = false; + var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 220 /* EnumDeclaration */) { + if (declaration.kind !== 221 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -27175,11 +27880,11 @@ var ts; } var firstEnumMember = enumDeclaration.members[0]; if (!firstEnumMember.initializer) { - if (seenEnumMissingInitialInitializer) { + if (seenEnumMissingInitialInitializer_1) { error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); } else { - seenEnumMissingInitialInitializer = true; + seenEnumMissingInitialInitializer_1 = true; } } }); @@ -27189,8 +27894,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 217 /* ClassDeclaration */ || - (declaration.kind === 216 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 218 /* ClassDeclaration */ || + (declaration.kind === 217 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -27233,6 +27938,7 @@ var ts; } checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. @@ -27251,7 +27957,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, 217 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 218 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -27260,10 +27966,10 @@ var ts; if (isAmbientExternalModule) { if (ts.isExternalModuleAugmentation(node)) { // body of the augmentation should be checked for consistency only if augmentation was applied to its target (either global scope or module) - // otherwise we'll be swamped in cascading errors. + // otherwise we'll be swamped in cascading errors. // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied - // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). + // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Merged */); if (checkBody) { // body of ambient external module is always a module block @@ -27297,31 +28003,31 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 230 /* ExportAssignment */: - case 231 /* ExportDeclaration */: + case 231 /* ExportAssignment */: + case 232 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: if (node.moduleReference.kind !== 9 /* StringLiteral */) { error(node.name, ts.Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope); break; } // fallthrough - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 166 /* BindingElement */: - case 214 /* VariableDeclaration */: - var name_17 = node.name; - if (ts.isBindingPattern(name_17)) { - for (var _b = 0, _c = name_17.elements; _b < _c.length; _b++) { + case 167 /* BindingElement */: + case 215 /* VariableDeclaration */: + var name_16 = node.name; + if (ts.isBindingPattern(name_16)) { + for (var _b = 0, _c = name_16.elements; _b < _c.length; _b++) { var el = _c[_b]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); @@ -27329,12 +28035,12 @@ var ts; break; } // fallthrough - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 216 /* FunctionDeclaration */: - case 218 /* InterfaceDeclaration */: - case 221 /* ModuleDeclaration */: - case 219 /* TypeAliasDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 217 /* FunctionDeclaration */: + case 219 /* InterfaceDeclaration */: + case 222 /* ModuleDeclaration */: + case 220 /* TypeAliasDeclaration */: var symbol = getSymbolOfNode(node); if (symbol) { // module augmentations cannot introduce new names on the top level scope of the module @@ -27361,10 +28067,10 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 136 /* QualifiedName */) { + if (node.kind === 137 /* QualifiedName */) { node = node.left; } - else if (node.kind === 169 /* PropertyAccessExpression */) { + else if (node.kind === 170 /* PropertyAccessExpression */) { node = node.expression; } else { @@ -27380,9 +28086,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 222 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 251 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 231 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 223 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 252 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 232 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -27409,7 +28115,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 === 233 /* ExportSpecifier */ ? + var message = node.kind === 234 /* 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)); @@ -27419,6 +28125,7 @@ var ts; function checkImportBinding(node) { checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); } function checkImportDeclaration(node) { @@ -27426,7 +28133,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -27436,7 +28143,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 228 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -27454,7 +28161,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -27473,7 +28180,7 @@ var ts; } } else { - if (modulekind === 5 /* ES6 */ && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.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_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -27485,7 +28192,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -27493,22 +28200,22 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 222 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 251 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 223 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 252 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } else { // export * from "foo" var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - if (moduleSymbol && moduleSymbol.exports["export="]) { + if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } } } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 251 /* SourceFile */ && node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 221 /* ModuleDeclaration */) { + if (node.parent.kind !== 252 /* SourceFile */ && node.parent.kind !== 223 /* ModuleBlock */ && node.parent.kind !== 222 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -27519,7 +28226,7 @@ var ts; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); } else { @@ -27532,13 +28239,13 @@ 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 === 251 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 221 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 252 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 222 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 959 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69 /* Identifier */) { @@ -27549,11 +28256,11 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === 5 /* ES6 */) { + if (modulekind === ts.ModuleKind.ES6) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (modulekind === 4 /* System */) { + else if (modulekind === ts.ModuleKind.System) { // system modules does not support export assignment grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } @@ -27585,12 +28292,21 @@ var ts; continue; } var _a = exports[id], declarations = _a.declarations, flags = _a.flags; - // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (!(flags & (1536 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) && (flags & 524288 /* TypeAlias */ ? declarations.length - 1 : declarations.length) > 1) { - var exportedDeclarations = ts.filter(declarations, isNotOverload); - if (exportedDeclarations.length > 1) { - for (var _i = 0, exportedDeclarations_1 = exportedDeclarations; _i < exportedDeclarations_1.length; _i++) { - var declaration = exportedDeclarations_1[_i]; + // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. + // (TS Exceptions: namespaces, function overloads, enums, and interfaces) + if (flags & (1536 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) { + continue; + } + var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); + if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + // it is legal to merge type alias with other values + // so count should be either 1 (just type alias) or 2 (type alias + merged value) + continue; + } + if (exportedDeclarationsCount > 1) { + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; + if (isNotOverload(declaration)) { diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, id)); } } @@ -27599,7 +28315,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 216 /* FunctionDeclaration */ || !!declaration.body; + return declaration.kind !== 217 /* FunctionDeclaration */ || !!declaration.body; } } function checkSourceElement(node) { @@ -27608,121 +28324,121 @@ var ts; } var kind = node.kind; if (cancellationToken) { - // Only bother checking on a few construct kinds. We don't want to be excessivly + // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 221 /* ModuleDeclaration */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: + case 222 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: return checkTypeParameter(node); - case 139 /* Parameter */: + case 140 /* Parameter */: return checkParameter(node); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return checkPropertyDeclaration(node); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: return checkSignatureDeclaration(node); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return checkMethodDeclaration(node); - case 145 /* Constructor */: + case 146 /* Constructor */: return checkConstructorDeclaration(node); - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return checkAccessorDeclaration(node); - case 152 /* TypeReference */: + case 153 /* TypeReference */: return checkTypeReferenceNode(node); - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: return checkTypePredicate(node); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return checkTypeQuery(node); - case 156 /* TypeLiteral */: + case 157 /* TypeLiteral */: return checkTypeLiteral(node); - case 157 /* ArrayType */: + case 158 /* ArrayType */: return checkArrayType(node); - case 158 /* TupleType */: + case 159 /* TupleType */: return checkTupleType(node); - case 159 /* UnionType */: - case 160 /* IntersectionType */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: return checkSourceElement(node.type); - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 195 /* Block */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return checkBlock(node); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return checkVariableStatement(node); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: return checkExpressionStatement(node); - case 199 /* IfStatement */: + case 200 /* IfStatement */: return checkIfStatement(node); - case 200 /* DoStatement */: + case 201 /* DoStatement */: return checkDoStatement(node); - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: return checkWhileStatement(node); - case 202 /* ForStatement */: + case 203 /* ForStatement */: return checkForStatement(node); - case 203 /* ForInStatement */: + case 204 /* ForInStatement */: return checkForInStatement(node); - case 204 /* ForOfStatement */: + case 205 /* ForOfStatement */: return checkForOfStatement(node); - case 205 /* ContinueStatement */: - case 206 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 207 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: return checkReturnStatement(node); - case 208 /* WithStatement */: + case 209 /* WithStatement */: return checkWithStatement(node); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: return checkSwitchStatement(node); - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return checkLabeledStatement(node); - case 211 /* ThrowStatement */: + case 212 /* ThrowStatement */: return checkThrowStatement(node); - case 212 /* TryStatement */: + case 213 /* TryStatement */: return checkTryStatement(node); - case 214 /* VariableDeclaration */: + case 215 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 166 /* BindingElement */: + case 167 /* BindingElement */: return checkBindingElement(node); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: return checkClassDeclaration(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: return checkImportDeclaration(node); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return checkExportDeclaration(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return checkExportAssignment(node); - case 197 /* EmptyStatement */: + case 198 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 213 /* DebuggerStatement */: + case 214 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 234 /* MissingDeclaration */: + case 235 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -27744,17 +28460,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: checkAccessorDeferred(node); break; - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -27829,7 +28545,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 208 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 209 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -27852,34 +28568,34 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 189 /* ClassExpression */: + case 190 /* 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 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* 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. // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 64 /* Static */)) { + if (!(memberFlags & 32 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 176 /* FunctionExpression */: + case 177 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -27928,37 +28644,48 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 138 /* TypeParameter */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 220 /* EnumDeclaration */: + case 139 /* TypeParameter */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 221 /* 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 === 136 /* QualifiedName */) { + while (node.parent && node.parent.kind === 137 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 152 /* TypeReference */; + return node.parent && node.parent.kind === 153 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 169 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 170 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 191 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 192 /* ExpressionWithTypeArguments */; + } + function isNodeWithinClass(node, classDeclaration) { + while (true) { + node = ts.getContainingClass(node); + if (!node) { + return false; + } + if (node === classDeclaration) { + return true; + } + } } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 136 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 137 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 225 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 230 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 231 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -27970,11 +28697,23 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 230 /* ExportAssignment */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 170 /* PropertyAccessExpression */) { + var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case 1 /* ExportsProperty */: + case 3 /* PrototypeProperty */: + return getSymbolOfNode(entityName.parent); + case 4 /* ThisProperty */: + case 2 /* ModuleExports */: + return getSymbolOfNode(entityName.parent.parent); + default: + } + } + if (entityName.parent.kind === 231 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 169 /* PropertyAccessExpression */) { + if (entityName.kind !== 170 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -27986,7 +28725,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 191 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 192 /* ExpressionWithTypeArguments */) { meaning = 793056 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -27999,10 +28738,10 @@ var ts; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 238 /* JsxOpeningElement */) || - (entityName.parent.kind === 237 /* JsxSelfClosingElement */) || - (entityName.parent.kind === 240 /* JsxClosingElement */)) { - return getJsxElementTagSymbol(entityName.parent); + else if ((entityName.parent.kind === 239 /* JsxOpeningElement */) || + (entityName.parent.kind === 238 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 241 /* JsxClosingElement */)) { + return getJsxTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { @@ -28015,14 +28754,14 @@ var ts; var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 169 /* PropertyAccessExpression */) { + else if (entityName.kind === 170 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 136 /* QualifiedName */) { + else if (entityName.kind === 137 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -28031,16 +28770,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 152 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 153 /* 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 === 241 /* JsxAttribute */) { + else if (entityName.parent.kind === 242 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 151 /* TypePredicate */) { + if (entityName.parent.kind === 152 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -28057,12 +28796,12 @@ var ts; } if (node.kind === 69 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 230 /* ExportAssignment */ + return node.parent.kind === 231 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } - else if (node.parent.kind === 166 /* BindingElement */ && - node.parent.parent.kind === 164 /* ObjectBindingPattern */ && + else if (node.parent.kind === 167 /* BindingElement */ && + node.parent.parent.kind === 165 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -28073,19 +28812,19 @@ var ts; } switch (node.kind) { case 69 /* Identifier */: - case 169 /* PropertyAccessExpression */: - case 136 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: + case 137 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 97 /* ThisKeyword */: case 95 /* SuperKeyword */: var type = ts.isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 162 /* ThisType */: + case 163 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 121 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 145 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 146 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -28093,14 +28832,14 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 225 /* ImportDeclaration */ || node.parent.kind === 231 /* ExportDeclaration */) && + ((node.parent.kind === 226 /* ImportDeclaration */ || node.parent.kind === 232 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 170 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 171 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -28117,7 +28856,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 === 249 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 250 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -28184,7 +28923,7 @@ var ts; */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 64 /* Static */ + return node.flags & 32 /* Static */ ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -28204,15 +28943,15 @@ var ts; } function getRootSymbols(symbol) { if (symbol.flags & 268435456 /* SyntheticProperty */) { - var symbols = []; - var name_18 = symbol.name; + var symbols_3 = []; + var name_17 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_18); + var symbol = getPropertyOfType(t, name_17); if (symbol) { - symbols.push(symbol); + symbols_3.push(symbol); } }); - return symbols; + return symbols_3; } else if (symbol.flags & 67108864 /* Transient */) { var target = getSymbolLinks(symbol).target; @@ -28232,7 +28971,7 @@ var ts; // module not found - be conservative return true; } - var hasExportAssignment = getExportAssignmentSymbol(moduleSymbol) !== undefined; + var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol); // if module has export assignment then 'resolveExternalModuleSymbol' will return resolved symbol for export assignment // otherwise it will return moduleSymbol itself moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); @@ -28267,11 +29006,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 251 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 252 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 221 /* ModuleDeclaration */ || n.kind === 220 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 222 /* ModuleDeclaration */ || n.kind === 221 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -28284,58 +29023,77 @@ var ts; var symbol = getReferencedValueSymbol(node); return symbol && symbol.flags & 8388608 /* Alias */ ? getDeclarationOfAliasSymbol(symbol) : undefined; } - function isStatementWithLocals(node) { - switch (node.kind) { - case 195 /* Block */: - case 223 /* CaseBlock */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - return true; - } - return false; - } - function isNestedRedeclarationSymbol(symbol) { + function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */) { var links = getSymbolLinks(symbol); - if (links.isNestedRedeclaration === undefined) { + if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (ts.isStatementWithLocals(container)) { + var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); + if (!!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + // redeclaration - always should be renamed + links.isDeclarationWithCollidingName = true; + } + else if (nodeLinks_1.flags & 131072 /* CapturedBlockScopedBinding */) { + // binding is captured in the function + // should be renamed if: + // - binding is not top level - top level bindings never collide with anything + // AND + // - binding is not declared in loop, should be renamed to avoid name reuse across siblings + // let a, b + // { let x = 1; a = () => x; } + // { let x = 100; b = () => x; } + // console.log(a()); // should print '1' + // console.log(b()); // should print '100' + // OR + // - binding is declared inside loop but not in inside initializer of iteration statement or directly inside loop body + // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly + // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus + // they will not collide with anything + var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; + var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 196 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); + } + else { + links.isDeclarationWithCollidingName = false; + } + } } - return links.isNestedRedeclaration; + return links.isDeclarationWithCollidingName; } return false; } // When resolved as an expression identifier, if the given node references a nested block scoped entity with - // a name that hides an existing name, return the declaration of that entity. Otherwise, return undefined. - function getReferencedNestedRedeclaration(node) { + // a name that either hides an existing name or might hide it when compiled downlevel, + // return the declaration of that entity. Otherwise, return undefined. + function getReferencedDeclarationWithCollidingName(node) { var symbol = getReferencedValueSymbol(node); - return symbol && isNestedRedeclarationSymbol(symbol) ? symbol.valueDeclaration : undefined; + return symbol && isSymbolOfDeclarationWithCollidingName(symbol) ? symbol.valueDeclaration : undefined; } - // Return true if the given node is a declaration of a nested block scoped entity with a name that hides an - // existing name. - function isNestedRedeclaration(node) { - return isNestedRedeclarationSymbol(getSymbolOfNode(node)); + // Return true if the given node is a declaration of a nested block scoped entity with a name that either hides an + // existing name or might hide a name when compiled downlevel + function isDeclarationWithCollidingName(node) { + return isSymbolOfDeclarationWithCollidingName(getSymbolOfNode(node)); } function isValueAliasDeclaration(node) { switch (node.kind) { - case 224 /* ImportEqualsDeclaration */: - case 226 /* ImportClause */: - case 227 /* NamespaceImport */: - case 229 /* ImportSpecifier */: - case 233 /* ExportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 227 /* ImportClause */: + case 228 /* NamespaceImport */: + case 230 /* ImportSpecifier */: + case 234 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return node.expression && node.expression.kind === 69 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 251 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 252 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -28347,7 +29105,7 @@ var ts; if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } - // const enums and modules that contain only const enums are not considered values from the emit perespective + // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true return target !== unknownSymbol && target && @@ -28397,7 +29155,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 250 /* EnumMember */) { + if (node.kind === 251 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -28432,22 +29190,22 @@ var ts; else if (type.flags & 1 /* Any */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (allConstituentTypesHaveKind(type, 16 /* Void */)) { + else if (isTypeOfKind(type, 16 /* Void */)) { return ts.TypeReferenceSerializationKind.VoidType; } - else if (allConstituentTypesHaveKind(type, 8 /* Boolean */)) { + else if (isTypeOfKind(type, 8 /* Boolean */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (allConstituentTypesHaveKind(type, 132 /* NumberLike */)) { + else if (isTypeOfKind(type, 132 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (allConstituentTypesHaveKind(type, 258 /* StringLike */)) { + else if (isTypeOfKind(type, 258 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } - else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { + else if (isTypeOfKind(type, 8192 /* Tuple */)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { + else if (isTypeOfKind(type, 16777216 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -28493,8 +29251,8 @@ var ts; return { getReferencedExportContainer: getReferencedExportContainer, getReferencedImportDeclaration: getReferencedImportDeclaration, - getReferencedNestedRedeclaration: getReferencedNestedRedeclaration, - isNestedRedeclaration: isNestedRedeclaration, + getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName, + isDeclarationWithCollidingName: isDeclarationWithCollidingName, isValueAliasDeclaration: isValueAliasDeclaration, hasGlobalName: hasGlobalName, isReferencedAliasDeclaration: isReferencedAliasDeclaration, @@ -28523,7 +29281,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 251 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 252 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -28536,7 +29294,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } - if (file.moduleAugmentations) { + if (file.moduleAugmentations.length) { (augmentations || (augmentations = [])).push(file.moduleAugmentations); } }); @@ -28599,6 +29357,9 @@ var ts; globalIterableIteratorType = emptyGenericType; } anyArrayType = createArrayType(anyType); + var symbol = getGlobalSymbol("ReadonlyArray", 793056 /* Type */, /*diagnostic*/ undefined); + globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); + anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); @@ -28624,14 +29385,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 144 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 145 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 146 /* GetAccessor */ || node.kind === 147 /* SetAccessor */) { + else if (node.kind === 147 /* GetAccessor */ || node.kind === 148 /* 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); @@ -28641,38 +29402,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 145 /* Constructor */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 150 /* IndexSignature */: - case 221 /* ModuleDeclaration */: - case 225 /* ImportDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 231 /* ExportDeclaration */: - case 230 /* ExportAssignment */: - case 139 /* Parameter */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 146 /* Constructor */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 151 /* IndexSignature */: + case 222 /* ModuleDeclaration */: + case 226 /* ImportDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 232 /* ExportDeclaration */: + case 231 /* ExportAssignment */: + case 140 /* Parameter */: break; - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 118 /* AsyncKeyword */) && - node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { + node.parent.kind !== 223 /* ModuleBlock */ && node.parent.kind !== 252 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 196 /* VariableStatement */: - case 219 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 197 /* VariableStatement */: + case 220 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 223 /* ModuleBlock */ && node.parent.kind !== 252 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 74 /* ConstKeyword */) && - node.parent.kind !== 222 /* ModuleBlock */ && node.parent.kind !== 251 /* SourceFile */) { + node.parent.kind !== 223 /* ModuleBlock */ && node.parent.kind !== 252 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -28682,42 +29443,48 @@ var ts; if (!node.modifiers) { return; } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync, lastReadonly; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; + if (modifier.kind !== 127 /* ReadonlyKeyword */) { + if (node.kind === 142 /* PropertySignature */ || node.kind === 144 /* MethodSignature */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); + } + if (node.kind === 151 /* IndexSignature */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); + } + } switch (modifier.kind) { case 74 /* ConstKeyword */: - if (node.kind !== 220 /* EnumDeclaration */ && node.parent.kind === 217 /* ClassDeclaration */) { + if (node.kind !== 221 /* EnumDeclaration */ && node.parent.kind === 218 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74 /* ConstKeyword */)); } break; case 112 /* PublicKeyword */: case 111 /* ProtectedKeyword */: case 110 /* PrivateKeyword */: - var text = void 0; - if (modifier.kind === 112 /* PublicKeyword */) { - text = "public"; - } - else if (modifier.kind === 111 /* ProtectedKeyword */) { - text = "protected"; + var text = visibilityToString(ts.modifierToFlag(modifier.kind)); + if (modifier.kind === 111 /* ProtectedKeyword */) { lastProtected = modifier; } - else { - text = "private"; + else if (modifier.kind === 110 /* PrivateKeyword */) { lastPrivate = modifier; } - if (flags & 56 /* AccessibilityModifier */) { + if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 64 /* Static */) { + else if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); + else if (node.parent.kind === 223 /* ModuleBlock */ || node.parent.kind === 252 /* SourceFile */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { if (modifier.kind === 110 /* PrivateKeyword */) { @@ -28730,29 +29497,42 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113 /* StaticKeyword */: - if (flags & 64 /* Static */) { + if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); + else if (node.parent.kind === 223 /* ModuleBlock */ || node.parent.kind === 252 /* SourceFile */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 139 /* Parameter */) { + else if (node.kind === 140 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 64 /* Static */; + flags |= 32 /* Static */; lastStatic = modifier; break; + case 127 /* ReadonlyKeyword */: + if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); + } + else if (node.kind !== 143 /* PropertyDeclaration */ && node.kind !== 142 /* PropertySignature */ && node.kind !== 151 /* IndexSignature */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); + } + flags |= 64 /* Readonly */; + lastReadonly = modifier; + break; case 82 /* ExportKeyword */: - if (flags & 2 /* Export */) { + if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 4 /* Ambient */) { + else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } else if (flags & 128 /* Abstract */) { @@ -28761,48 +29541,51 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 217 /* ClassDeclaration */) { + else if (node.parent.kind === 218 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 139 /* Parameter */) { + else if (node.kind === 140 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 2 /* Export */; + flags |= 1 /* Export */; break; case 122 /* DeclareKeyword */: - if (flags & 4 /* Ambient */) { + if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 217 /* ClassDeclaration */) { + else if (node.parent.kind === 218 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 139 /* Parameter */) { + else if (node.kind === 140 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 222 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 223 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 4 /* Ambient */; + flags |= 2 /* Ambient */; lastDeclare = modifier; break; case 115 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 217 /* ClassDeclaration */) { - if (node.kind !== 144 /* MethodDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + if (node.kind !== 218 /* ClassDeclaration */) { + if (node.kind !== 145 /* MethodDeclaration */ && + node.kind !== 143 /* PropertyDeclaration */ && + node.kind !== 147 /* GetAccessor */ && + node.kind !== 148 /* SetAccessor */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 217 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { + if (!(node.parent.kind === 218 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 64 /* Static */) { + if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 16 /* Private */) { + if (flags & 8 /* Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } @@ -28812,10 +29595,10 @@ var ts; if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 4 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + 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 === 139 /* Parameter */) { + else if (node.kind === 140 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -28823,28 +29606,25 @@ var ts; break; } } - if (node.kind === 145 /* Constructor */) { - if (flags & 64 /* Static */) { + if (node.kind === 146 /* Constructor */) { + if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 32 /* Protected */) { - return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & 16 /* Private */) { - return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly"); + } return; } - else if ((node.kind === 225 /* ImportDeclaration */ || node.kind === 224 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { + else if ((node.kind === 226 /* ImportDeclaration */ || node.kind === 225 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 139 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 140 /* Parameter */ && (flags & 28 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 256 /* Async */) { @@ -28856,10 +29636,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 144 /* MethodDeclaration */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -28925,7 +29705,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 177 /* ArrowFunction */) { + if (node.kind === 178 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -28948,7 +29728,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 1022 /* Modifier */) { + if (parameter.flags & 959 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -28960,21 +29740,16 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 130 /* StringKeyword */ && parameter.type.kind !== 128 /* NumberKeyword */) { + if (parameter.type.kind !== 131 /* StringKeyword */ && parameter.type.kind !== 129 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); } } - function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 1022 /* Modifier */) { - grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } function checkGrammarIndexSignature(node) { // Prevent cascading error by short-circuit - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node); + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node); } function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) { if (typeArguments && typeArguments.length === 0) { @@ -28993,7 +29768,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { var arg = args_1[_i]; - if (arg.kind === 190 /* OmittedExpression */) { + if (arg.kind === 191 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -29067,19 +29842,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 137 /* ComputedPropertyName */) { + if (node.kind !== 138 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 184 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 185 /* 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 === 216 /* FunctionDeclaration */ || - node.kind === 176 /* FunctionExpression */ || - node.kind === 144 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 217 /* FunctionDeclaration */ || + node.kind === 177 /* FunctionExpression */ || + node.kind === 145 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -29100,28 +29875,28 @@ var ts; var seen = {}; var Property = 1; var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; + var SetAccessor = 4; + var GetOrSetAccessor = GetAccessor | SetAccessor; var _loop_1 = function(prop) { - var name_19 = prop.name; - if (prop.kind === 190 /* OmittedExpression */ || - name_19.kind === 137 /* ComputedPropertyName */) { + var name_18 = prop.name; + if (prop.kind === 191 /* OmittedExpression */ || + name_18.kind === 138 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_19); + checkGrammarComputedPropertyName(name_18); return "continue"; } - if (prop.kind === 249 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 250 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) }; } // Modifiers are never allowed on properties except for 'async' on a method declaration ts.forEach(prop.modifiers, function (mod) { - if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 144 /* MethodDeclaration */) { + if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 145 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } }); - // ECMA-262 11.1.5 Object Initialiser + // ECMA-262 11.1.5 Object Initializer // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and // IsDataDescriptor(propId.descriptor) is true. @@ -29130,71 +29905,71 @@ 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 === 248 /* PropertyAssignment */ || prop.kind === 249 /* ShorthandPropertyAssignment */) { - // Grammar checking for computedPropertName and shorthandPropertyAssignment + if (prop.kind === 249 /* PropertyAssignment */ || prop.kind === 250 /* ShorthandPropertyAssignment */) { + // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_19.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_19); + if (name_18.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_18); } currentKind = Property; } - else if (prop.kind === 144 /* MethodDeclaration */) { + else if (prop.kind === 145 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 146 /* GetAccessor */) { + else if (prop.kind === 147 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 147 /* SetAccessor */) { - currentKind = SetAccesor; + else if (prop.kind === 148 /* SetAccessor */) { + currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_19.text)) { - seen[name_19.text] = currentKind; + if (!ts.hasProperty(seen, name_18.text)) { + seen[name_18.text] = currentKind; } else { - var existingKind = seen[name_19.text]; + var existingKind = seen[name_18.text]; if (currentKind === Property && existingKind === Property) { return "continue"; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_19.text] = currentKind | existingKind; + seen[name_18.text] = currentKind | existingKind; } else { - return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; + return { value: grammarErrorOnNode(name_18, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) }; } } else { - return { value: grammarErrorOnNode(name_19, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; + return { value: grammarErrorOnNode(name_18, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name) }; } } }; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var state_1 = _loop_1(prop); - if (typeof state_1 === "object") return state_1.value - if (state_1 === "continue") continue; + var state_2 = _loop_1(prop); + if (typeof state_2 === "object") return state_2.value; + if (state_2 === "continue") continue; } } function checkGrammarJsxElement(node) { var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 242 /* JsxSpreadAttribute */) { + if (attr.kind === 243 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_20 = jsxAttr.name; - if (!ts.hasProperty(seen, name_20.text)) { - seen[name_20.text] = true; + var name_19 = jsxAttr.name; + if (!ts.hasProperty(seen, name_19.text)) { + seen[name_19.text] = true; } else { - return grammarErrorOnNode(name_20, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_19, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 243 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 244 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -29203,7 +29978,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 215 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 216 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -29218,20 +29993,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 203 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 204 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 203 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 204 /* 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 === 203 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 204 /* 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); @@ -29248,16 +30023,16 @@ var ts; else if (ts.isInAmbientContext(accessor)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); } - else if (accessor.body === undefined) { + else if (accessor.body === undefined && !(accessor.flags & 128 /* Abstract */)) { return grammarErrorAtPos(ts.getSourceFileOfNode(accessor), accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 146 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 147 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 147 /* SetAccessor */) { + else if (kind === 148 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -29269,7 +30044,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 1022 /* Modifier */) { + else if (parameter.flags & 959 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -29292,7 +30067,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 168 /* ObjectLiteralExpression */) { + if (node.parent.kind === 169 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -29316,10 +30091,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 218 /* InterfaceDeclaration */) { + else if (node.parent.kind === 219 /* 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 === 156 /* TypeLiteral */) { + else if (node.parent.kind === 157 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -29330,11 +30105,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 210 /* LabeledStatement */: + case 211 /* 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 === 205 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 206 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -29342,8 +30117,8 @@ var ts; return false; } break; - case 209 /* SwitchStatement */: - if (node.kind === 206 /* BreakStatement */ && !node.label) { + case 210 /* SwitchStatement */: + if (node.kind === 207 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -29358,13 +30133,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 206 /* BreakStatement */ + var message = node.kind === 207 /* 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 === 206 /* BreakStatement */ + var message = node.kind === 207 /* 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); @@ -29376,7 +30151,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 === 165 /* ArrayBindingPattern */ || node.name.kind === 164 /* ObjectBindingPattern */) { + if (node.name.kind === 166 /* ArrayBindingPattern */ || node.name.kind === 165 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -29386,7 +30161,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 203 /* ForInStatement */ && node.parent.parent.kind !== 204 /* ForOfStatement */) { + if (node.parent.parent.kind !== 204 /* ForInStatement */ && node.parent.parent.kind !== 205 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -29422,7 +30197,7 @@ var ts; var elements = name.elements; for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { var element = elements_2[_i]; - if (element.kind !== 190 /* OmittedExpression */) { + if (element.kind !== 191 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -29439,15 +30214,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 199 /* IfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 208 /* WithStatement */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 200 /* IfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 209 /* WithStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: return false; - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -29503,7 +30278,7 @@ var ts; return true; } } - else if (node.parent.kind === 218 /* InterfaceDeclaration */) { + else if (node.parent.kind === 219 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -29511,7 +30286,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 156 /* TypeLiteral */) { + else if (node.parent.kind === 157 /* 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; } @@ -29536,14 +30311,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 218 /* InterfaceDeclaration */ || - node.kind === 219 /* TypeAliasDeclaration */ || - node.kind === 225 /* ImportDeclaration */ || - node.kind === 224 /* ImportEqualsDeclaration */ || - node.kind === 231 /* ExportDeclaration */ || - node.kind === 230 /* ExportAssignment */ || - (node.flags & 4 /* Ambient */) || - (node.flags & (2 /* Export */ | 512 /* Default */))) { + if (node.kind === 219 /* InterfaceDeclaration */ || + node.kind === 220 /* TypeAliasDeclaration */ || + node.kind === 226 /* ImportDeclaration */ || + node.kind === 225 /* ImportEqualsDeclaration */ || + node.kind === 232 /* ExportDeclaration */ || + node.kind === 231 /* ExportAssignment */ || + (node.flags & 2 /* Ambient */) || + (node.flags & (1 /* Export */ | 512 /* Default */))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -29551,7 +30326,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 === 196 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 197 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -29574,10 +30349,10 @@ var ts; } // We are either parented by another statement, or some sort of block. // If we're in a block, we only want to really report an error once - // to prevent noisyness. So use a bit on the block to indicate if + // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 195 /* Block */ || node.parent.kind === 222 /* ModuleBlock */ || node.parent.kind === 251 /* SourceFile */) { + if (node.parent.kind === 196 /* Block */ || node.parent.kind === 223 /* ModuleBlock */ || node.parent.kind === 252 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -29590,7 +30365,7 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 32768 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + if (node.isOctalLiteral && languageVersion >= 1 /* ES5 */) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -29611,6 +30386,14 @@ var ts; var ts; (function (ts) { var nullSourceMapWriter; + // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans + var defaultLastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; function getNullSourceMapWriter() { if (nullSourceMapWriter === undefined) { nullSourceMapWriter = { @@ -29664,13 +30447,7 @@ var ts; sourceMapSourceIndex = -1; // Last recorded and encoded spans lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; + lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; lastEncodedNameIndex = 0; // Initialize source map data sourceMapData = { @@ -29733,10 +30510,12 @@ var ts; lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; // Pop sourceMapDecodedMappings to remove last entry sourceMapData.sourceMapDecodedMappings.pop(); - // Change the last encoded source map + // Point the lastEncodedSourceMapSpace to the previous encoded sourceMapSpan + // If the list is empty which indicates that we are at the beginning of the file, + // we have to reset it to default value (same value when we first initialize sourceMapWriter) lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - undefined; + defaultLastEncodedSourceMapSpan; // TODO: Update lastEncodedNameIndex // Since we dont support this any more, lets not worry about it right now. // When we start supporting nameIndex, we will get back to this @@ -29944,7 +30723,8 @@ var ts; var increaseIndent; var decreaseIndent; var writeTextOfNode; - var writer = createAndSetNewTextWriterWithSymbolWriter(); + var writer; + createAndSetNewTextWriterWithSymbolWriter(); var enclosingDeclaration; var resultHasExternalModuleIndicator; var currentText; @@ -30008,7 +30788,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 225 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 226 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -30064,7 +30844,6 @@ var ts; writer.writeParameter = writer.write; writer.writeSymbol = writer.write; setWriter(writer); - return writer; } function setWriter(newWriter) { writer = newWriter; @@ -30078,10 +30857,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 214 /* VariableDeclaration */) { + if (declaration.kind === 215 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 228 /* NamedImports */ || declaration.kind === 229 /* ImportSpecifier */ || declaration.kind === 226 /* ImportClause */) { + else if (declaration.kind === 229 /* NamedImports */ || declaration.kind === 230 /* ImportSpecifier */ || declaration.kind === 227 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -30099,7 +30878,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 === 225 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 226 /* 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; @@ -30109,12 +30888,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 221 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 222 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 221 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 222 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -30124,23 +30903,23 @@ var ts; }); setWriter(oldWriter); } - function handleSymbolAccessibilityError(symbolAccesibilityResult) { - if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { + function handleSymbolAccessibilityError(symbolAccessibilityResult) { + if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { // write the aliases - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsynchronousModuleElements(symbolAccesibilityResult.aliasesToMakeVisible); + if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { + writeAsynchronousModuleElements(symbolAccessibilityResult.aliasesToMakeVisible); } } else { // Report error reportedDeclarationError = true; - var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); + var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccessibilityResult); if (errorInfo) { if (errorInfo.typeName) { - emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNodeFromSourceText(currentText, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNodeFromSourceText(currentText, errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } else { - emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + emitterDiagnostics.add(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } } } @@ -30217,40 +30996,40 @@ var ts; function emitType(type) { switch (type.kind) { case 117 /* AnyKeyword */: - case 130 /* StringKeyword */: - case 128 /* NumberKeyword */: + case 131 /* StringKeyword */: + case 129 /* NumberKeyword */: case 120 /* BooleanKeyword */: - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: case 103 /* VoidKeyword */: - case 162 /* ThisType */: - case 163 /* StringLiteralType */: + case 163 /* ThisType */: + case 164 /* StringLiteralType */: return writeTextOfNode(currentText, type); - case 191 /* ExpressionWithTypeArguments */: + case 192 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 152 /* TypeReference */: + case 153 /* TypeReference */: return emitTypeReference(type); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return emitTypeQuery(type); - case 157 /* ArrayType */: + case 158 /* ArrayType */: return emitArrayType(type); - case 158 /* TupleType */: + case 159 /* TupleType */: return emitTupleType(type); - case 159 /* UnionType */: + case 160 /* UnionType */: return emitUnionType(type); - case 160 /* IntersectionType */: + case 161 /* IntersectionType */: return emitIntersectionType(type); - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: return emitParenType(type); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 156 /* TypeLiteral */: + case 157 /* TypeLiteral */: return emitTypeLiteral(type); case 69 /* Identifier */: return emitEntityName(type); - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return emitEntityName(type); - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -30258,8 +31037,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 136 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 136 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 137 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 137 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -30268,13 +31047,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 224 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 225 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 169 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 170 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -30353,9 +31132,9 @@ var ts; var count = 0; while (true) { count++; - var name_21 = baseName + "_" + count; - if (!ts.hasProperty(currentIdentifiers, name_21)) { - return name_21; + var name_20 = baseName + "_" + count; + if (!ts.hasProperty(currentIdentifiers, name_20)) { + return name_20; } } } @@ -30399,10 +31178,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 224 /* ImportEqualsDeclaration */ || - (node.parent.kind === 251 /* SourceFile */ && isCurrentFileExternalModule)) { - var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 251 /* SourceFile */) { + else if (node.kind === 225 /* ImportEqualsDeclaration */ || + (node.parent.kind === 252 /* SourceFile */ && isCurrentFileExternalModule)) { + var isVisible = void 0; + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 252 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -30412,7 +31191,7 @@ var ts; }); } else { - if (node.kind === 225 /* ImportDeclaration */) { + if (node.kind === 226 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -30430,23 +31209,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return writeVariableStatement(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: return writeClassDeclaration(node); - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -30454,30 +31233,33 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 251 /* SourceFile */) { + if (node.parent.kind === 252 /* SourceFile */) { // If the node is exported - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { write("export "); } if (node.flags & 512 /* Default */) { write("default "); } - else if (node.kind !== 218 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 219 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } } - function emitClassMemberDeclarationFlags(node) { - if (node.flags & 16 /* Private */) { + function emitClassMemberDeclarationFlags(flags) { + if (flags & 8 /* Private */) { write("private "); } - else if (node.flags & 32 /* Protected */) { + else if (flags & 16 /* Protected */) { write("protected "); } - if (node.flags & 64 /* Static */) { + if (flags & 32 /* Static */) { write("static "); } - if (node.flags & 128 /* Abstract */) { + if (flags & 64 /* Readonly */) { + write("readonly "); + } + if (flags & 128 /* Abstract */) { write("abstract "); } } @@ -30485,7 +31267,7 @@ var ts; // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { write("export "); } write("import "); @@ -30501,7 +31283,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult) { + function getImportEntityNameVisibilityError(symbolAccessibilityResult) { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -30511,7 +31293,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 227 /* NamespaceImport */) { + if (namedBindings.kind === 228 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -30520,12 +31302,8 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 2 /* Export */)) { - // do not write non-exported import declarations that don't have import clauses - return; - } emitJsDocComments(node); - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { write("export "); } write("import "); @@ -30539,7 +31317,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 228 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -30558,15 +31336,15 @@ var ts; function emitExternalModuleSpecifier(parent) { // emitExternalModuleSpecifier is usually called when we emit something in the.d.ts file that will make it an external module (i.e. import/export declarations). // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered - // external modules since they are indistingushable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' + // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 221 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 222 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 224 /* ImportEqualsDeclaration */) { + if (parent.kind === 225 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 221 /* ModuleDeclaration */) { + else if (parent.kind === 222 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -30623,7 +31401,7 @@ var ts; write("global "); } else { - if (node.flags & 65536 /* Namespace */) { + if (node.flags & 4096 /* Namespace */) { write("namespace "); } else { @@ -30636,7 +31414,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body.kind !== 222 /* ModuleBlock */) { + while (node.body.kind !== 223 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -30665,7 +31443,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -30701,7 +31479,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 144 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); + return node.parent.kind === 145 /* MethodDeclaration */ && (node.parent.flags & 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -30712,50 +31490,50 @@ 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 === 153 /* FunctionType */ || - node.parent.kind === 154 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 156 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 144 /* MethodDeclaration */ || - node.parent.kind === 143 /* MethodSignature */ || - node.parent.kind === 153 /* FunctionType */ || - node.parent.kind === 154 /* ConstructorType */ || - node.parent.kind === 148 /* CallSignature */ || - node.parent.kind === 149 /* ConstructSignature */); + if (node.parent.kind === 154 /* FunctionType */ || + node.parent.kind === 155 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 157 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 145 /* MethodDeclaration */ || + node.parent.kind === 144 /* MethodSignature */ || + node.parent.kind === 154 /* FunctionType */ || + node.parent.kind === 155 /* ConstructorType */ || + node.parent.kind === 149 /* CallSignature */ || + node.parent.kind === 150 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 148 /* CallSignature */: + case 149 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - if (node.parent.flags & 64 /* Static */) { + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + if (node.parent.flags & 32 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 217 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 218 /* 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 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -30786,10 +31564,10 @@ var ts; else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { write("null"); } - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + function getHeritageClauseVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 217 /* ClassDeclaration */) { + if (node.parent.parent.kind === 218 /* 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 : @@ -30811,7 +31589,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 56 /* AccessibilityModifier */) { + if (param.flags & 28 /* AccessibilityModifier */) { emitPropertyDeclaration(param); } }); @@ -30865,7 +31643,7 @@ var ts; return; } emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags); emitVariableDeclaration(node); write(";"); writeLine(); @@ -30873,7 +31651,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 !== 214 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 215 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -30883,51 +31661,51 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentText, node.name); // If optional property emit ? - if ((node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 143 /* PropertyDeclaration */ || node.kind === 142 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) && node.parent.kind === 156 /* TypeLiteral */) { + if ((node.kind === 143 /* PropertyDeclaration */ || node.kind === 142 /* PropertySignature */) && node.parent.kind === 157 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 16 /* Private */)) { + else if (!(node.flags & 8 /* Private */)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } } - function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 214 /* VariableDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { + if (node.kind === 215 /* VariableDeclaration */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 142 /* PropertyDeclaration */ || node.kind === 141 /* PropertySignature */) { + else if (node.kind === 143 /* PropertyDeclaration */ || node.kind === 142 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. - if (node.flags & 64 /* Static */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + if (node.flags & 32 /* Static */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 217 /* ClassDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + else if (node.parent.kind === 218 /* ClassDeclaration */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { // Interfaces cannot have types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; } } } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, @@ -30943,15 +31721,15 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 190 /* OmittedExpression */) { + if (element.kind !== 191 /* OmittedExpression */) { elements.push(element); } } emitCommaList(elements, emitBindingElement); } function emitBindingElement(bindingElement) { - function getBindingElementTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getBindingElementTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: bindingElement, @@ -31006,14 +31784,14 @@ var ts; if (node === accessors.firstAccessor) { emitJsDocComments(accessors.getAccessor); emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); + emitClassMemberDeclarationFlags(node.flags | (accessors.setAccessor ? 0 : 64 /* Readonly */)); writeTextOfNode(currentText, node.name); - if (!(node.flags & 16 /* Private */)) { + if (!(node.flags & 8 /* Private */)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 146 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 147 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -31026,24 +31804,24 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 146 /* GetAccessor */ + return accessor.kind === 147 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type : undefined; } } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 147 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 148 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named - if (accessorWithTypeAnnotation.parent.flags & 64 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + if (accessorWithTypeAnnotation.parent.flags & 32 /* Static */) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; } @@ -31055,16 +31833,16 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 64 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + if (accessorWithTypeAnnotation.flags & 32 /* Static */) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; } else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; @@ -31085,17 +31863,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 216 /* FunctionDeclaration */) { + if (node.kind === 217 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 144 /* MethodDeclaration */) { - emitClassMemberDeclarationFlags(node); + else if (node.kind === 145 /* MethodDeclaration */ || node.kind === 146 /* Constructor */) { + emitClassMemberDeclarationFlags(node.flags); } - if (node.kind === 216 /* FunctionDeclaration */) { + if (node.kind === 217 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 145 /* Constructor */) { + else if (node.kind === 146 /* Constructor */) { write("constructor"); } else { @@ -31114,35 +31892,37 @@ var ts; function emitSignatureDeclaration(node) { var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; - // Construct signature or constructor type write new Signature - if (node.kind === 149 /* ConstructSignature */ || node.kind === 154 /* ConstructorType */) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 150 /* IndexSignature */) { + if (node.kind === 151 /* IndexSignature */) { + // Index signature can have readonly modifier + emitClassMemberDeclarationFlags(node.flags); write("["); } else { + // Construct signature or constructor type write new Signature + if (node.kind === 150 /* ConstructSignature */ || node.kind === 155 /* ConstructorType */) { + write("new "); + } + emitTypeParameters(node.typeParameters); write("("); } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 150 /* IndexSignature */) { + if (node.kind === 151 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 153 /* FunctionType */ || node.kind === 154 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 156 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 154 /* FunctionType */ || node.kind === 155 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 157 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 145 /* Constructor */ && !(node.flags & 16 /* Private */)) { + else if (node.kind !== 146 /* Constructor */ && !(node.flags & 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -31150,53 +31930,53 @@ var ts; write(";"); writeLine(); } - function getReturnTypeVisibilityError(symbolAccesibilityResult) { + function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 148 /* CallSignature */: + case 149 /* CallSignature */: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - if (node.flags & 64 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + if (node.flags & 32 /* Static */) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : 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 === 217 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + else if (node.parent.kind === 218 /* ClassDeclaration */) { + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { // Interfaces cannot have return types that cannot be named - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 216 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 217 /* FunctionDeclaration */: + diagnosticMessage = symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -31229,65 +32009,65 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 153 /* FunctionType */ || - node.parent.kind === 154 /* ConstructorType */ || - node.parent.parent.kind === 156 /* TypeLiteral */) { + if (node.parent.kind === 154 /* FunctionType */ || + node.parent.kind === 155 /* ConstructorType */ || + node.parent.parent.kind === 157 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 16 /* Private */)) { + else if (!(node.parent.flags & 8 /* Private */)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult); + function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) { + var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult); return diagnosticMessage !== undefined ? { diagnosticMessage: diagnosticMessage, errorNode: node, typeName: node.name } : undefined; } - function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { + function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 145 /* Constructor */: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 146 /* Constructor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 148 /* CallSignature */: + case 149 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - if (node.parent.flags & 64 /* Static */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + if (node.parent.flags & 32 /* Static */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : 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 === 217 /* ClassDeclaration */) { - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + else if (node.parent.parent.kind === 218 /* ClassDeclaration */) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { // Interfaces cannot have parameter types that cannot be named - return symbolAccesibilityResult.errorModuleName ? + return symbolAccessibilityResult.errorModuleName ? 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 216 /* FunctionDeclaration */: - return symbolAccesibilityResult.errorModuleName ? - symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? + case 217 /* FunctionDeclaration */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; @@ -31297,12 +32077,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 === 164 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 165 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 165 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 166 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -31313,7 +32093,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 190 /* OmittedExpression */) { + if (bindingElement.kind === 191 /* 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) @@ -31322,7 +32102,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 166 /* BindingElement */) { + else if (bindingElement.kind === 167 /* 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" @@ -31361,40 +32141,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 216 /* FunctionDeclaration */: - case 221 /* ModuleDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 218 /* InterfaceDeclaration */: - case 217 /* ClassDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 220 /* EnumDeclaration */: + case 217 /* FunctionDeclaration */: + case 222 /* ModuleDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 219 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 221 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return emitExportDeclaration(node); - case 145 /* Constructor */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 146 /* Constructor */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return writeFunctionDeclaration(node); - case 149 /* ConstructSignature */: - case 148 /* CallSignature */: - case 150 /* IndexSignature */: + case 150 /* ConstructSignature */: + case 149 /* CallSignature */: + case 151 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return emitAccessorDeclaration(node); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return emitPropertyDeclaration(node); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return emitExportAssignment(node); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return emitSourceFile(node); } } @@ -31744,6 +32524,11 @@ var ts; TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; TempFlags[TempFlags["_i"] = 268435456] = "_i"; })(TempFlags || (TempFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile) { // emit output for the __extends helper function @@ -31754,7 +32539,7 @@ var ts; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; // emit output for the __param helper function var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new P(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.call(thisArg, _arguments)).next());\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -31830,9 +32615,11 @@ var ts; // => // var x;... exporter("x", x = 1) var exportFunctionForFile; + var contextObjectForFile; var generatedNameSet; var nodeToGeneratedName; var computedPropertyNamesToGeneratedNames; + var decoratedClassAliases; var convertedLoopState; var extendsEmitted; var decorateEmitted; @@ -31854,19 +32641,19 @@ var ts; var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; var setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer) { }; var moduleEmitDelegates = (_a = {}, - _a[5 /* ES6 */] = emitES6Module, - _a[2 /* AMD */] = emitAMDModule, - _a[4 /* System */] = emitSystemModule, - _a[3 /* UMD */] = emitUMDModule, - _a[1 /* CommonJS */] = emitCommonJSModule, + _a[ts.ModuleKind.ES6] = emitES6Module, + _a[ts.ModuleKind.AMD] = emitAMDModule, + _a[ts.ModuleKind.System] = emitSystemModule, + _a[ts.ModuleKind.UMD] = emitUMDModule, + _a[ts.ModuleKind.CommonJS] = emitCommonJSModule, _a ); var bundleEmitDelegates = (_b = {}, - _b[5 /* ES6 */] = function () { }, - _b[2 /* AMD */] = emitAMDModule, - _b[4 /* System */] = emitSystemModule, - _b[3 /* UMD */] = function () { }, - _b[1 /* CommonJS */] = function () { }, + _b[ts.ModuleKind.ES6] = function () { }, + _b[ts.ModuleKind.AMD] = emitAMDModule, + _b[ts.ModuleKind.System] = emitSystemModule, + _b[ts.ModuleKind.UMD] = function () { }, + _b[ts.ModuleKind.CommonJS] = function () { }, _b ); return doEmit; @@ -31874,6 +32661,7 @@ var ts; sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); generatedNameSet = {}; nodeToGeneratedName = []; + decoratedClassAliases = []; isOwnFileEmit = !isBundledEmit; // Emit helpers from all the files if (isBundledEmit && modulekind) { @@ -31894,8 +32682,10 @@ var ts; currentText = undefined; currentLineMap = undefined; exportFunctionForFile = undefined; + contextObjectForFile = undefined; generatedNameSet = undefined; nodeToGeneratedName = undefined; + decoratedClassAliases = undefined; computedPropertyNamesToGeneratedNames = undefined; convertedLoopState = undefined; extendsEmitted = false; @@ -31920,6 +32710,7 @@ var ts; currentText = sourceFile.text; currentLineMap = ts.getLineStarts(sourceFile); exportFunctionForFile = undefined; + contextObjectForFile = undefined; isEs6Module = sourceFile.symbol && sourceFile.symbol.exports && !!sourceFile.symbol.exports["___esModule"]; renamedDependencies = sourceFile.renamedDependencies; currentFileIdentifiers = sourceFile.identifiers; @@ -31937,10 +32728,10 @@ var ts; // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_22 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_22)) { + var name_21 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_21)) { tempFlags |= flags; - return name_22; + return name_21; } } while (true) { @@ -31948,9 +32739,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_23 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_23)) { - return name_23; + var name_22 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_22)) { + return name_22; } } } @@ -31994,17 +32785,17 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return makeUniqueName(node.text); - case 221 /* ModuleDeclaration */: - case 220 /* EnumDeclaration */: + case 222 /* ModuleDeclaration */: + case 221 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 225 /* ImportDeclaration */: - case 231 /* ExportDeclaration */: + case 226 /* ImportDeclaration */: + case 232 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 216 /* FunctionDeclaration */: - case 217 /* ClassDeclaration */: - case 230 /* ExportAssignment */: + case 217 /* FunctionDeclaration */: + case 218 /* ClassDeclaration */: + case 231 /* ExportAssignment */: return generateNameForExportDefault(); - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -32232,7 +33023,7 @@ var ts; // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". var text = ts.getTextOfNodeFromSourceText(currentText, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // text contains the original source, it will also contain quotes ("`"), dollar signs and braces ("${" and "}"), // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" @@ -32274,10 +33065,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 186 /* TemplateExpression */) { + if (node.template.kind === 187 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 184 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 185 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -32312,7 +33103,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 175 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 176 /* 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 @@ -32354,11 +33145,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: return parent.expression === template; - case 173 /* TaggedTemplateExpression */: - case 175 /* ParenthesizedExpression */: + case 174 /* TaggedTemplateExpression */: + case 176 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -32379,7 +33170,7 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: switch (expression.operatorToken.kind) { case 37 /* AsteriskToken */: case 39 /* SlashToken */: @@ -32391,8 +33182,8 @@ var ts; default: return -1 /* LessThan */; } - case 187 /* YieldExpression */: - case 185 /* ConditionalExpression */: + case 188 /* YieldExpression */: + case 186 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -32459,12 +33250,12 @@ 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 === 242 /* JsxSpreadAttribute */; })) { + if (ts.forEach(attrs, function (attr) { return attr.kind === 243 /* JsxSpreadAttribute */; })) { emitExpressionIdentifier(syntheticReactRef); write(".__spread("); var haveOpenedObjectLiteral = false; for (var i = 0; i < attrs.length; i++) { - if (attrs[i].kind === 242 /* JsxSpreadAttribute */) { + if (attrs[i].kind === 243 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument if (i === 0) { write("{}, "); @@ -32479,7 +33270,7 @@ var ts; emit(attrs[i].expression); } else { - ts.Debug.assert(attrs[i].kind === 241 /* JsxAttribute */); + ts.Debug.assert(attrs[i].kind === 242 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } @@ -32511,23 +33302,45 @@ var ts; } // Children if (children) { - for (var i = 0; i < children.length; i++) { - // Don't emit empty expressions - if (children[i].kind === 243 /* JsxExpression */ && !(children[i].expression)) { - continue; - } - // Don't emit empty strings - if (children[i].kind === 239 /* JsxText */) { - var text = getTextToEmit(children[i]); - if (text !== undefined) { - write(", \""); - write(text); - write("\""); + var firstChild = void 0; + var multipleEmittableChildren = false; + for (var i = 0, n = children.length; i < n; i++) { + var jsxChild = children[i]; + if (isJsxChildEmittable(jsxChild)) { + // we need to decide whether to emit in single line or multiple lines as indented list + // store firstChild reference, if we see another emittable child, then emit accordingly + if (!firstChild) { + write(", "); + firstChild = jsxChild; + } + else { + // more than one emittable child, emit indented list + if (!multipleEmittableChildren) { + multipleEmittableChildren = true; + increaseIndent(); + writeLine(); + emit(firstChild); + } + write(", "); + writeLine(); + emit(jsxChild); } } + } + if (multipleEmittableChildren) { + decreaseIndent(); + } + else if (firstChild) { + if (firstChild.kind !== 237 /* JsxElement */ && firstChild.kind !== 238 /* JsxSelfClosingElement */) { + emit(firstChild); + } else { - write(", "); - emit(children[i]); + // If the only child is jsx element, put it on a new indented line + increaseIndent(); + writeLine(); + emit(firstChild); + writeLine(); + decreaseIndent(); } } } @@ -32535,11 +33348,11 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 236 /* JsxElement */) { + if (node.kind === 237 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 237 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 238 /* JsxSelfClosingElement */); emitJsxElement(node); } } @@ -32561,11 +33374,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 242 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 243 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 241 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 242 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -32573,11 +33386,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 237 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 238 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 237 /* JsxSelfClosingElement */) { + if (node.kind === 238 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -32596,11 +33409,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 236 /* JsxElement */) { + if (node.kind === 237 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 237 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 238 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -32608,11 +33421,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 !== 166 /* BindingElement */); + ts.Debug.assert(node.kind !== 167 /* BindingElement */); if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 137 /* ComputedPropertyName */) { + else if (node.kind === 138 /* 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: @@ -32656,76 +33469,72 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* ArrayLiteralExpression */: - case 192 /* AsExpression */: - case 184 /* BinaryExpression */: - case 171 /* CallExpression */: - case 244 /* CaseClause */: - case 137 /* ComputedPropertyName */: - case 185 /* ConditionalExpression */: - case 140 /* Decorator */: - case 178 /* DeleteExpression */: - case 200 /* DoStatement */: - case 170 /* ElementAccessExpression */: - case 230 /* ExportAssignment */: - case 198 /* ExpressionStatement */: - case 191 /* ExpressionWithTypeArguments */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 199 /* IfStatement */: - case 240 /* JsxClosingElement */: - case 237 /* JsxSelfClosingElement */: - case 238 /* JsxOpeningElement */: - case 242 /* JsxSpreadAttribute */: - case 243 /* JsxExpression */: - case 172 /* NewExpression */: - case 175 /* ParenthesizedExpression */: - case 183 /* PostfixUnaryExpression */: - case 182 /* PrefixUnaryExpression */: - case 207 /* ReturnStatement */: - case 249 /* ShorthandPropertyAssignment */: - case 188 /* SpreadElementExpression */: - case 209 /* SwitchStatement */: - case 173 /* TaggedTemplateExpression */: - case 193 /* TemplateSpan */: - case 211 /* ThrowStatement */: - case 174 /* TypeAssertionExpression */: - case 179 /* TypeOfExpression */: - case 180 /* VoidExpression */: - case 201 /* WhileStatement */: - case 208 /* WithStatement */: - case 187 /* YieldExpression */: + case 168 /* ArrayLiteralExpression */: + case 193 /* AsExpression */: + case 185 /* BinaryExpression */: + case 172 /* CallExpression */: + case 245 /* CaseClause */: + case 138 /* ComputedPropertyName */: + case 186 /* ConditionalExpression */: + case 141 /* Decorator */: + case 179 /* DeleteExpression */: + case 201 /* DoStatement */: + case 171 /* ElementAccessExpression */: + case 231 /* ExportAssignment */: + case 199 /* ExpressionStatement */: + case 192 /* ExpressionWithTypeArguments */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 200 /* IfStatement */: + case 241 /* JsxClosingElement */: + case 238 /* JsxSelfClosingElement */: + case 239 /* JsxOpeningElement */: + case 243 /* JsxSpreadAttribute */: + case 244 /* JsxExpression */: + case 173 /* NewExpression */: + case 176 /* ParenthesizedExpression */: + case 184 /* PostfixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: + case 208 /* ReturnStatement */: + case 250 /* ShorthandPropertyAssignment */: + case 189 /* SpreadElementExpression */: + case 210 /* SwitchStatement */: + case 174 /* TaggedTemplateExpression */: + case 194 /* TemplateSpan */: + case 212 /* ThrowStatement */: + case 175 /* TypeAssertionExpression */: + case 180 /* TypeOfExpression */: + case 181 /* VoidExpression */: + case 202 /* WhileStatement */: + case 209 /* WithStatement */: + case 188 /* YieldExpression */: return true; - case 166 /* BindingElement */: - case 250 /* EnumMember */: - case 139 /* Parameter */: - case 248 /* PropertyAssignment */: - case 142 /* PropertyDeclaration */: - case 214 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 251 /* EnumMember */: + case 140 /* Parameter */: + case 249 /* PropertyAssignment */: + case 143 /* PropertyDeclaration */: + case 215 /* VariableDeclaration */: return parent.initializer === node; - case 169 /* PropertyAccessExpression */: + case 170 /* PropertyAccessExpression */: return parent.expression === node; - case 177 /* ArrowFunction */: - case 176 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 177 /* FunctionExpression */: return parent.body === node; - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return parent.left === node; } return false; } function emitExpressionIdentifier(node) { - if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { - write("_arguments"); - return; - } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 251 /* SourceFile */) { + if (container.kind === 252 /* SourceFile */) { // Identifier references module export - if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + if (modulekind !== ts.ModuleKind.ES6 && modulekind !== ts.ModuleKind.System) { write("exports."); } } @@ -32736,20 +33545,20 @@ var ts; } } else { - if (modulekind !== 5 /* ES6 */) { + if (modulekind !== ts.ModuleKind.ES6) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 226 /* ImportClause */) { + if (declaration.kind === 227 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 229 /* ImportSpecifier */) { + else if (declaration.kind === 230 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - var name_24 = declaration.propertyName || declaration.name; - var identifier = ts.getTextOfNodeFromSourceText(currentText, name_24); + var name_23 = declaration.propertyName || declaration.name; + var identifier = ts.getTextOfNodeFromSourceText(currentText, name_23); if (languageVersion === 0 /* ES3 */ && identifier === "default") { write("[\"default\"]"); } @@ -32761,13 +33570,26 @@ var ts; } } } - if (languageVersion !== 2 /* ES6 */) { - var declaration = resolver.getReferencedNestedRedeclaration(node); + if (languageVersion < 2 /* ES6 */) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration) { write(getGeneratedNameForNode(declaration.name)); return; } } + else if (resolver.getNodeCheckFlags(node) & 1048576 /* BodyScopedClassBinding */) { + // Due to the emit for class decorators, any reference to the class from inside of the class body + // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind + // behavior of class names in ES6. + var declaration = resolver.getReferencedValueDeclaration(node); + if (declaration) { + var classAlias = decoratedClassAliases[ts.getNodeId(declaration)]; + if (classAlias !== undefined) { + write(classAlias); + return; + } + } + } } if (ts.nodeIsSynthesized(node)) { write(node.text); @@ -32776,15 +33598,15 @@ var ts; writeTextOfNode(currentText, node); } } - function isNameOfNestedRedeclaration(node) { + function isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node) { if (languageVersion < 2 /* ES6 */) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 166 /* BindingElement */: - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 214 /* VariableDeclaration */: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_8 = node.parent; + switch (parent_8.kind) { + case 167 /* BindingElement */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 215 /* VariableDeclaration */: + return parent_8.name === node && resolver.isDeclarationWithCollidingName(parent_8); } } return false; @@ -32793,8 +33615,8 @@ var ts; if (convertedLoopState) { if (node.text == "arguments" && resolver.isArgumentsLocalBinding(node)) { // in converted loop body arguments cannot be used directly. - var name_25 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); - write(name_25); + var name_24 = convertedLoopState.argumentsName || (convertedLoopState.argumentsName = makeUniqueName("arguments")); + write(name_24); return; } } @@ -32804,7 +33626,7 @@ var ts; else if (isExpressionIdentifier(node)) { emitExpressionIdentifier(node); } - else if (isNameOfNestedRedeclaration(node)) { + else if (isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(node)) { write(getGeneratedNameForNode(node)); } else if (ts.nodeIsSynthesized(node)) { @@ -32894,10 +33716,10 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 184 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 185 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 185 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 186 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; @@ -32905,11 +33727,11 @@ var ts; function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { case 69 /* Identifier */: - case 167 /* ArrayLiteralExpression */: - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: - case 171 /* CallExpression */: - case 175 /* ParenthesizedExpression */: + case 168 /* ArrayLiteralExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: + case 172 /* CallExpression */: + case 176 /* 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; @@ -32929,17 +33751,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 188 /* SpreadElementExpression */) { + if (e.kind === 189 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 167 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 168 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 188 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 189 /* SpreadElementExpression */) { i++; } write("["); @@ -32962,7 +33784,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 188 /* SpreadElementExpression */; + return node.kind === 189 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -32975,7 +33797,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 1024 /* MultiLine */) !== 0, + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ node.multiLine, /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } @@ -32994,7 +33816,7 @@ var ts; emitLinePreservingList(node, properties, /*allowTrailingComma*/ languageVersion >= 1 /* ES5 */, /*spacesBetweenBraces*/ true); } else { - var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; + var multiLine = node.multiLine; if (!multiLine) { write(" "); } @@ -33013,7 +33835,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; + var multiLine = node.multiLine; var properties = node.properties; write("("); if (multiLine) { @@ -33032,7 +33854,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 146 /* GetAccessor */ || property.kind === 147 /* SetAccessor */) { + if (property.kind === 147 /* GetAccessor */ || property.kind === 148 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -33084,13 +33906,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 248 /* PropertyAssignment */) { + if (property.kind === 249 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 249 /* ShorthandPropertyAssignment */) { + else if (property.kind === 250 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 144 /* MethodDeclaration */) { + else if (property.kind === 145 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -33124,7 +33946,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 === 137 /* ComputedPropertyName */) { + if (properties[i].name.kind === 138 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -33140,21 +33962,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(184 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(185 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(169 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(170 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(170 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(171 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -33162,7 +33984,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 === 174 /* TypeAssertionExpression */ || expr.kind === 192 /* AsExpression */) { + while (expr.kind === 175 /* TypeAssertionExpression */ || expr.kind === 193 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -33174,11 +33996,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 172 /* NewExpression */ && + expr.kind !== 173 /* NewExpression */ && expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(175 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(176 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -33213,7 +34035,7 @@ var ts; // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 251 /* SourceFile */; + return container && container.kind !== 252 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -33228,7 +34050,7 @@ var ts; // let obj = { y }; // } // Here we need to emit obj = { y : m.y } regardless of the output target. - if (modulekind !== 5 /* ES6 */ || isNamespaceExportReference(node.name)) { + if (modulekind !== ts.ModuleKind.ES6 || isNamespaceExportReference(node.name)) { // Emit identifier as an identifier write(": "); emit(node.name); @@ -33243,7 +34065,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 169 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 170 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -33254,7 +34076,7 @@ var ts; if (compilerOptions.isolatedModules) { return undefined; } - return node.kind === 169 /* PropertyAccessExpression */ || node.kind === 170 /* ElementAccessExpression */ + return node.kind === 170 /* PropertyAccessExpression */ || node.kind === 171 /* ElementAccessExpression */ ? resolver.getConstantValue(node) : undefined; } @@ -33281,6 +34103,14 @@ var ts; if (tryEmitConstantValue(node)) { return; } + if (languageVersion === 2 /* ES6 */ && + node.expression.kind === 95 /* SuperKeyword */ && + isInAsyncMethodWithSuperInES6(node)) { + var name_25 = ts.createSynthesizedNode(9 /* StringLiteral */); + name_25.text = node.name.text; + emitSuperAccessInAsyncMethod(node.expression, name_25); + return; + } emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal @@ -33343,7 +34173,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; default: @@ -33355,16 +34185,22 @@ var ts; if (tryEmitConstantValue(node)) { return; } + if (languageVersion === 2 /* ES6 */ && + node.expression.kind === 95 /* SuperKeyword */ && + isInAsyncMethodWithSuperInES6(node)) { + emitSuperAccessInAsyncMethod(node.expression, node.argumentExpression); + return; + } emit(node.expression); write("["); emit(node.argumentExpression); write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 188 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 189 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 175 /* ParenthesizedExpression */ || node.kind === 174 /* TypeAssertionExpression */ || node.kind === 192 /* AsExpression */) { + while (node.kind === 176 /* ParenthesizedExpression */ || node.kind === 175 /* TypeAssertionExpression */ || node.kind === 193 /* AsExpression */) { node = node.expression; } return node; @@ -33385,13 +34221,13 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 169 /* PropertyAccessExpression */) { + if (expr.kind === 170 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 170 /* ElementAccessExpression */) { + else if (expr.kind === 171 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); @@ -33424,23 +34260,42 @@ var ts; emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); } + function isInAsyncMethodWithSuperInES6(node) { + if (languageVersion === 2 /* ES6 */) { + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); + if (container && resolver.getNodeCheckFlags(container) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */)) { + return true; + } + } + return false; + } + function emitSuperAccessInAsyncMethod(superNode, argumentExpression) { + var container = ts.getSuperContainer(superNode, /*includeFunctions*/ false); + var isSuperBinding = resolver.getNodeCheckFlags(container) & 4096 /* AsyncMethodWithSuperBinding */; + write("_super("); + emit(argumentExpression); + write(isSuperBinding ? ").value" : ")"); + } function emitCallExpression(node) { if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { emitCallWithSpread(node); return; } + var expression = node.expression; var superCall = false; - if (node.expression.kind === 95 /* SuperKeyword */) { - emitSuper(node.expression); + var isAsyncMethodWithSuper = false; + if (expression.kind === 95 /* SuperKeyword */) { + emitSuper(expression); superCall = true; } else { - emit(node.expression); - superCall = node.expression.kind === 169 /* PropertyAccessExpression */ && node.expression.expression.kind === 95 /* SuperKeyword */; + superCall = ts.isSuperPropertyOrElementAccess(expression); + isAsyncMethodWithSuper = superCall && isInAsyncMethodWithSuperInES6(node); + emit(expression); } - if (superCall && languageVersion < 2 /* ES6 */) { + if (superCall && (languageVersion < 2 /* ES6 */ || isAsyncMethodWithSuper)) { write(".call("); - emitThis(node.expression); + emitThis(expression); if (node.arguments.length) { write(", "); emitCommaList(node.arguments); @@ -33505,12 +34360,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 !== 177 /* ArrowFunction */) { - if (node.expression.kind === 174 /* TypeAssertionExpression */ || node.expression.kind === 192 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 178 /* ArrowFunction */) { + if (node.expression.kind === 175 /* TypeAssertionExpression */ || node.expression.kind === 193 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 174 /* TypeAssertionExpression */ || operand.kind === 192 /* AsExpression */) { + while (operand.kind === 175 /* TypeAssertionExpression */ || operand.kind === 193 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -33521,15 +34376,15 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 182 /* PrefixUnaryExpression */ && - operand.kind !== 180 /* VoidExpression */ && - operand.kind !== 179 /* TypeOfExpression */ && - operand.kind !== 178 /* DeleteExpression */ && - operand.kind !== 183 /* PostfixUnaryExpression */ && - operand.kind !== 172 /* NewExpression */ && - !(operand.kind === 171 /* CallExpression */ && node.parent.kind === 172 /* NewExpression */) && - !(operand.kind === 176 /* FunctionExpression */ && node.parent.kind === 171 /* CallExpression */) && - !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 169 /* PropertyAccessExpression */)) { + if (operand.kind !== 183 /* PrefixUnaryExpression */ && + operand.kind !== 181 /* VoidExpression */ && + operand.kind !== 180 /* TypeOfExpression */ && + operand.kind !== 179 /* DeleteExpression */ && + operand.kind !== 184 /* PostfixUnaryExpression */ && + operand.kind !== 173 /* NewExpression */ && + !(operand.kind === 172 /* CallExpression */ && node.parent.kind === 173 /* NewExpression */) && + !(operand.kind === 177 /* FunctionExpression */ && node.parent.kind === 172 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 170 /* PropertyAccessExpression */)) { emit(operand); return; } @@ -33558,7 +34413,7 @@ var ts; if (!isCurrentFileSystemExternalModule() || node.kind !== 69 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 214 /* VariableDeclaration */ || node.parent.kind === 166 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 215 /* VariableDeclaration */ || node.parent.kind === 167 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -33589,7 +34444,7 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 182 /* PrefixUnaryExpression */) { + if (node.operand.kind === 183 /* PrefixUnaryExpression */) { var operand = node.operand; if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) { write(" "); @@ -33643,12 +34498,12 @@ var ts; if (!node || !isCurrentFileSystemExternalModule()) { return false; } - var current = node; + var current = ts.getRootDeclaration(node).parent; while (current) { - if (current.kind === 251 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 2 /* Export */) !== 0); + if (current.kind === 252 /* SourceFile */) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 222 /* ModuleBlock */) { + else if (ts.isDeclaration(current)) { return false; } else { @@ -33663,12 +34518,12 @@ var ts; function emitExponentiationOperator(node) { var leftHandSideExpression = node.left; if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { - var synthesizedLHS; + var synthesizedLHS = void 0; var shouldEmitParentheses = false; if (ts.isElementAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(170 /* ElementAccessExpression */, /*startsOnNewLine*/ false); + synthesizedLHS = ts.createSynthesizedNode(171 /* ElementAccessExpression */, /*startsOnNewLine*/ false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; if (leftHandSideExpression.argumentExpression.kind !== 8 /* NumericLiteral */ && @@ -33685,7 +34540,7 @@ var ts; else if (ts.isPropertyAccessExpression(leftHandSideExpression)) { shouldEmitParentheses = true; write("("); - synthesizedLHS = ts.createSynthesizedNode(169 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); + synthesizedLHS = ts.createSynthesizedNode(170 /* PropertyAccessExpression */, /*startsOnNewLine*/ false); var identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false); synthesizedLHS.expression = identifier; synthesizedLHS.dotToken = leftHandSideExpression.dotToken; @@ -33713,8 +34568,8 @@ var ts; } function emitBinaryExpression(node) { if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 56 /* EqualsToken */ && - (node.left.kind === 168 /* ObjectLiteralExpression */ || node.left.kind === 167 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 198 /* ExpressionStatement */); + (node.left.kind === 169 /* ObjectLiteralExpression */ || node.left.kind === 168 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 199 /* ExpressionStatement */); } else { var exportChanged = node.operatorToken.kind >= 56 /* FirstAssignment */ && @@ -33779,7 +34634,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 195 /* Block */) { + if (node && node.kind === 196 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -33793,12 +34648,12 @@ var ts; } emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); - if (node.kind === 222 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 221 /* ModuleDeclaration */); + if (node.kind === 223 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 222 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 222 /* ModuleBlock */) { + if (node.kind === 223 /* ModuleBlock */) { emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); @@ -33806,7 +34661,7 @@ var ts; emitToken(16 /* CloseBraceToken */, node.statements.end); } function emitEmbeddedStatement(node) { - if (node.kind === 195 /* Block */) { + if (node.kind === 196 /* Block */) { write(" "); emit(node); } @@ -33818,7 +34673,7 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 177 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 178 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { @@ -33831,7 +34686,7 @@ var ts; if (node.elseStatement) { writeLine(); emitToken(80 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 199 /* IfStatement */) { + if (node.elseStatement.kind === 200 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -33851,7 +34706,7 @@ var ts; else { emitNormalLoopBody(node, /*emitAsEmbeddedStatement*/ true); } - if (node.statement.kind === 195 /* Block */) { + if (node.statement.kind === 196 /* Block */) { write(" "); } else { @@ -33885,7 +34740,7 @@ var ts; // variables in variable declaration list were already hoisted return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576 /* BlockScoped */) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 3072 /* BlockScoped */) === 0) { // we are inside a converted loop - this can only happen in downlevel scenarios // record names for all variable declarations for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { @@ -33932,7 +34787,7 @@ var ts; } function shouldConvertLoopBody(node) { return languageVersion < 2 /* ES6 */ && - (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithBlockScopedBindingCapturedInFunction */) !== 0; + (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; } function emitLoop(node, loopEmitter) { var shouldConvert = shouldConvertLoopBody(node); @@ -33941,7 +34796,7 @@ var ts; } else { var loop = convertLoopBody(node); - if (node.parent.kind === 210 /* LabeledStatement */) { + if (node.parent.kind === 211 /* LabeledStatement */) { // if parent of the loop was labeled statement - attach the label to loop skipping converted loop body emitLabelAndColon(node.parent); } @@ -33952,35 +34807,31 @@ var ts; var functionName = makeUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 215 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 216 /* VariableDeclarationList */) { loopInitializer = node.initializer; } break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576 /* BlockScoped */)) { + var loopOutParameters; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3072 /* BlockScoped */)) { // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { var varDeclaration = _b[_a]; - collectNames(varDeclaration.name); + processVariableDeclaration(varDeclaration.name); } } - var bodyIsBlock = node.statement.kind === 195 /* Block */; + var bodyIsBlock = node.statement.kind === 196 /* Block */; var paramList = loopParameters ? loopParameters.join(", ") : ""; writeLine(); write("var " + functionName + " = function(" + paramList + ")"); - if (!bodyIsBlock) { - write(" {"); - writeLine(); - increaseIndent(); - } var convertedOuterLoopState = convertedLoopState; - convertedLoopState = {}; + convertedLoopState = { loopOutParameters: loopOutParameters }; if (convertedOuterLoopState) { // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. // if outer converted loop has already accumulated some state - pass it through @@ -34000,14 +34851,34 @@ var ts; convertedLoopState.hoistedLocalVariables = convertedOuterLoopState.hoistedLocalVariables; } } - emitEmbeddedStatement(node.statement); - if (!bodyIsBlock) { - decreaseIndent(); - writeLine(); - write("}"); - } - write(";"); + write(" {"); writeLine(); + increaseIndent(); + if (bodyIsBlock) { + emitLines(node.statement.statements); + } + else { + emit(node.statement); + } + writeLine(); + // end of loop body -> copy out parameter + copyLoopOutParameters(convertedLoopState, 1 /* ToOutParameter */, /*emitAsStatements*/ true); + decreaseIndent(); + writeLine(); + write("};"); + writeLine(); + if (loopOutParameters) { + // declare variables to hold out params for loop body + write("var "); + for (var i = 0; i < loopOutParameters.length; i++) { + if (i !== 0) { + write(", "); + } + write(loopOutParameters[i].outParamName); + } + write(";"); + writeLine(); + } if (convertedLoopState.argumentsName) { // if alias for arguments is set if (convertedOuterLoopState) { @@ -34044,7 +34915,7 @@ var ts; else { // deduplicate and hoist collected variable declarations write("var "); - var seen; + var seen = void 0; for (var _c = 0, _d = convertedLoopState.hoistedLocalVariables; _c < _d.length; _c++) { var id = _d[_c]; // Don't initialize seen unless we have at least one element. @@ -34067,15 +34938,21 @@ var ts; var currentLoopState = convertedLoopState; convertedLoopState = convertedOuterLoopState; return { functionName: functionName, paramList: paramList, state: currentLoopState }; - function collectNames(name) { + function processVariableDeclaration(name) { if (name.kind === 69 /* Identifier */) { - var nameText = isNameOfNestedRedeclaration(name) ? getGeneratedNameForNode(name) : name.text; + var nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(name) + ? getGeneratedNameForNode(name) + : name.text; loopParameters.push(nameText); + if (resolver.getNodeCheckFlags(name.parent) & 2097152 /* NeedsLoopOutParameter */) { + var reassignedVariable = { originalName: name, outParamName: makeUniqueName("out_" + nameText) }; + (loopOutParameters || (loopOutParameters = [])).push(reassignedVariable); + } } else { for (var _a = 0, _b = name.elements; _a < _b.length; _a++) { var element = _b[_a]; - collectNames(element.name); + processVariableDeclaration(element.name); } } } @@ -34091,7 +34968,7 @@ var ts; if (emitAsEmbeddedStatement) { emitEmbeddedStatement(node.statement); } - else if (node.statement.kind === 195 /* Block */) { + else if (node.statement.kind === 196 /* Block */) { emitLines(node.statement.statements); } else { @@ -34102,6 +34979,28 @@ var ts; convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } } + function copyLoopOutParameters(state, copyDirection, emitAsStatements) { + if (state.loopOutParameters) { + for (var _a = 0, _b = state.loopOutParameters; _a < _b.length; _a++) { + var outParam = _b[_a]; + if (copyDirection === 0 /* ToOriginal */) { + emitIdentifier(outParam.originalName); + write(" = " + outParam.outParamName); + } + else { + write(outParam.outParamName + " = "); + emitIdentifier(outParam.originalName); + } + if (emitAsStatements) { + write(";"); + writeLine(); + } + else { + write(", "); + } + } + } + } function emitConvertedLoopCall(loop, emitAsBlock) { if (emitAsBlock) { write(" {"); @@ -34118,6 +35017,8 @@ var ts; write("var " + loopResult + " = "); } write(loop.functionName + "(" + loop.paramList + ");"); + writeLine(); + copyLoopOutParameters(loop.state, 0 /* ToOriginal */, /*emitAsStatements*/ true); if (!isSimpleLoop) { // for non simple loops we need to store result returned from converted loop function and use it to do dispatching // converted loop function can return: @@ -34135,7 +35036,7 @@ var ts; } else { // top level converted loop - return unwrapped value - write("return " + loopResult + ".value"); + write("return " + loopResult + ".value;"); } writeLine(); } @@ -34201,7 +35102,7 @@ var ts; var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 216 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList); if (startIsEmitted) { @@ -34227,7 +35128,7 @@ var ts; } } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 204 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 205 /* ForOfStatement */) { emitLoop(node, emitDownLevelForOfStatementWorker); } else { @@ -34238,7 +35139,7 @@ var ts; var endPos = emitToken(86 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(17 /* OpenParenToken */, endPos); - if (node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList); @@ -34248,7 +35149,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 203 /* ForInStatement */) { + if (node.kind === 204 /* ForInStatement */) { write(" in "); } else { @@ -34338,7 +35239,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 215 /* VariableDeclarationList */) { + if (node.initializer.kind === 216 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -34368,7 +35269,7 @@ var ts; // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. var assignmentExpression = createBinaryExpression(node.initializer, 56 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); - if (node.initializer.kind === 167 /* ArrayLiteralExpression */ || node.initializer.kind === 168 /* ObjectLiteralExpression */) { + if (node.initializer.kind === 168 /* ArrayLiteralExpression */ || node.initializer.kind === 169 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); @@ -34396,23 +35297,26 @@ var ts; // it is possible if either // - break\continue is statement labeled and label is located inside the converted loop // - break\continue is non-labeled and located in non-converted loop\switch statement - var jump = node.kind === 206 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 207 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { + write("return "); + // explicit exit from loop -> copy out parameters + copyLoopOutParameters(convertedLoopState, 1 /* ToOutParameter */, /*emitAsStatements*/ false); if (!node.label) { - if (node.kind === 206 /* BreakStatement */) { + if (node.kind === 207 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; - write("return \"break\";"); + write("\"break\";"); } else { convertedLoopState.nonLocalJumps |= 4 /* Continue */; - write("return \"continue\";"); + write("\"continue\";"); } } else { - var labelMarker; - if (node.kind === 206 /* BreakStatement */) { + var labelMarker = void 0; + if (node.kind === 207 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -34420,12 +35324,12 @@ var ts; labelMarker = "continue-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); } - write("return \"" + labelMarker + "\";"); + write("\"" + labelMarker + "\";"); } return; } } - emitToken(node.kind === 206 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 207 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } @@ -34491,7 +35395,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap(currentLineMap, ts.skipTrivia(currentText, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 244 /* CaseClause */) { + if (node.kind === 245 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -34560,7 +35464,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 221 /* ModuleDeclaration */); + } while (node && node.kind !== 222 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -34569,13 +35473,13 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 2 /* Export */) { + if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); write("."); } - else if (modulekind !== 5 /* ES6 */ && modulekind !== 4 /* System */) { + else if (modulekind !== ts.ModuleKind.ES6 && modulekind !== ts.ModuleKind.System) { write("exports."); } } @@ -34585,15 +35489,15 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(180 /* VoidExpression */); + var result = ts.createSynthesizedNode(181 /* VoidExpression */); result.expression = zero; return result; } function emitEs6ExportDefaultCompat(node) { - if (node.parent.kind === 251 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 230 /* ExportAssignment */); + if (node.parent.kind === 252 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 231 /* ExportAssignment */); // only allow export default at a source file level - if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { + if (modulekind === ts.ModuleKind.CommonJS || modulekind === ts.ModuleKind.AMD || modulekind === ts.ModuleKind.UMD) { if (!isEs6Module) { if (languageVersion !== 0 /* ES3 */) { // default value of configurable, enumerable, writable are `false`. @@ -34609,11 +35513,11 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { writeLine(); emitStart(node); // emit call to exporter only for top level nodes - if (modulekind === 4 /* System */ && node.parent === currentSourceFile) { + if (modulekind === ts.ModuleKind.System && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); @@ -34648,7 +35552,7 @@ var ts; } } function emitExportMemberAssignments(name) { - if (modulekind === 4 /* System */) { + if (modulekind === ts.ModuleKind.System) { return; } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { @@ -34667,7 +35571,7 @@ var ts; } } function emitExportSpecifierInSystemModule(specifier) { - ts.Debug.assert(modulekind === 4 /* System */); + ts.Debug.assert(modulekind === ts.ModuleKind.System); if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { return; } @@ -34697,7 +35601,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 214 /* VariableDeclaration */ || name.parent.kind === 166 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 215 /* VariableDeclaration */ || name.parent.kind === 167 /* BindingElement */); // If this is first var declaration, we need to start at var/let/const keyword instead // otherwise use nodeForSourceMap as the start position emitStart(isFirstVariableDeclaration(nodeForSourceMap) ? nodeForSourceMap.parent : nodeForSourceMap); @@ -34731,8 +35635,8 @@ var ts; return identifier; } function isFirstVariableDeclaration(root) { - return root.kind === 214 /* VariableDeclaration */ && - root.parent.kind === 215 /* VariableDeclarationList */ && + return root.kind === 215 /* VariableDeclaration */ && + root.parent.kind === 216 /* VariableDeclarationList */ && root.parent.declarations[0] === root; } function emitDestructuring(root, isAssignmentExpressionStatement, value) { @@ -34742,15 +35646,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 === 214 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 2 /* Export */; + if (root.kind === 215 /* VariableDeclaration */) { + var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 139 /* Parameter */) { + else if (root.kind === 140 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 184 /* BinaryExpression */) { + if (root.kind === 185 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -34785,14 +35689,14 @@ var ts; // If the temporary variable needs to be emitted use the source Map node for assignment of that statement value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(184 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(185 /* BinaryExpression */); equals.left = value; equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(185 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(186 /* ConditionalExpression */); cond.condition = condition; cond.questionToken = ts.createSynthesizedNode(53 /* QuestionToken */); cond.whenTrue = whenTrue; @@ -34807,7 +35711,7 @@ var ts; } function createPropertyAccessForDestructuringProperty(object, propName) { var index; - var nameIsComputed = propName.kind === 137 /* ComputedPropertyName */; + var nameIsComputed = propName.kind === 138 /* ComputedPropertyName */; if (nameIsComputed) { // TODO to handle when we look into sourcemaps for computed properties, for now use propName index = ensureIdentifier(propName.expression, /*reuseIdentifierExpressions*/ false, propName); @@ -34816,14 +35720,18 @@ var ts; // We create a synthetic copy of the identifier in order to avoid the rewriting that might // otherwise occur when the identifier is emitted. index = ts.createSynthesizedNode(propName.kind); - index.text = propName.text; + // We need to unescape identifier here because when parsing an identifier prefixing with "__" + // the parser need to append "_" in order to escape colliding with magic identifiers such as "__proto__" + // Therefore, in order to correctly emit identifiers that are written in original TypeScript file, + // we will unescapeIdentifier to remove additional underscore (if no underscore is added, the function will return original input string) + index.text = ts.unescapeIdentifier(propName.text); } return !nameIsComputed && index.kind === 69 /* Identifier */ ? createPropertyAccessExpression(object, index) : createElementAccessExpression(object, index); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(171 /* CallExpression */); + var call = ts.createSynthesizedNode(172 /* CallExpression */); var sliceIdentifier = ts.createSynthesizedNode(69 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); @@ -34836,15 +35744,15 @@ var ts; if (properties.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - // When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment + // When doing so we want to highlight the passed in source map node since thats the one needing this temp assignment value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode); } for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { var p = properties_5[_a]; - if (p.kind === 248 /* PropertyAssignment */ || p.kind === 249 /* ShorthandPropertyAssignment */) { + if (p.kind === 249 /* PropertyAssignment */ || p.kind === 250 /* ShorthandPropertyAssignment */) { var propName = p.name; - var target_1 = p.kind === 249 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; - // Assignment for target = value.propName should highligh whole property, hence use p as source map node + var target_1 = p.kind === 250 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + // Assignment for target = value.propName should highlight whole property, hence use p as source map node emitDestructuringAssignment(target_1, createPropertyAccessForDestructuringProperty(value, propName), p); } } @@ -34854,14 +35762,14 @@ var ts; if (elements.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - // When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment + // When doing so we want to highlight the passed in source map node since thats the one needing this temp assignment value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, sourceMapNode); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 190 /* OmittedExpression */) { - // Assignment for target = value.propName should highligh whole property, hence use e as source map node - if (e.kind !== 188 /* SpreadElementExpression */) { + if (e.kind !== 191 /* OmittedExpression */) { + // Assignment for target = value.propName should highlight whole property, hence use e as source map node + if (e.kind !== 189 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)), e); } else if (i === elements.length - 1) { @@ -34872,20 +35780,20 @@ var ts; } function emitDestructuringAssignment(target, value, sourceMapNode) { // When emitting target = value use source map node to highlight, including any temporary assignments needed for this - if (target.kind === 249 /* ShorthandPropertyAssignment */) { + if (target.kind === 250 /* ShorthandPropertyAssignment */) { if (target.objectAssignmentInitializer) { value = createDefaultValueCheck(value, target.objectAssignmentInitializer, sourceMapNode); } target = target.name; } - else if (target.kind === 184 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + else if (target.kind === 185 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right, sourceMapNode); target = target.left; } - if (target.kind === 168 /* ObjectLiteralExpression */) { + if (target.kind === 169 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, sourceMapNode); } - else if (target.kind === 167 /* ArrayLiteralExpression */) { + else if (target.kind === 168 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value, sourceMapNode); } else { @@ -34907,7 +35815,7 @@ var ts; emitDestructuringAssignment(target, value, ts.nodeIsSynthesized(root) ? target : root); } else { - if (root.parent.kind !== 175 /* ParenthesizedExpression */) { + if (root.parent.kind !== 176 /* ParenthesizedExpression */) { write("("); } // Temporary assignment needed to emit root should highlight whole binary expression @@ -34916,7 +35824,7 @@ var ts; emitDestructuringAssignment(target, value, root); write(", "); emit(value); - if (root.parent.kind !== 175 /* ParenthesizedExpression */) { + if (root.parent.kind !== 176 /* ParenthesizedExpression */) { write(")"); } } @@ -34944,12 +35852,12 @@ var ts; } for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 164 /* ObjectBindingPattern */) { + if (pattern.kind === 165 /* 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 !== 190 /* OmittedExpression */) { + else if (element.kind !== 191 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -34978,19 +35886,46 @@ var ts; } else { var initializer = node.initializer; - if (!initializer && languageVersion < 2 /* ES6 */) { - // downlevel emit for non-initialized let bindings defined in loops - // for (...) { let x; } - // should be - // for (...) { var = void 0; } - // this is necessary to preserve ES6 semantic in scenarios like - // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 8192 /* Let */); - // NOTE: default initialization should not be added to let bindings in for-in\for-of statements - if (isLetDefinedInLoop && - node.parent.parent.kind !== 203 /* ForInStatement */ && - node.parent.parent.kind !== 204 /* ForOfStatement */) { + if (!initializer && + languageVersion < 2 /* ES6 */ && + // for names - binding patterns that lack initializer there is no point to emit explicit initializer + // since downlevel codegen for destructuring will fail in the absence of initializer so all binding elements will say uninitialized + node.name.kind === 69 /* Identifier */) { + var container = ts.getEnclosingBlockScopeContainer(node); + var flags = resolver.getNodeCheckFlags(node); + // nested let bindings might need to be initialized explicitly to preserve ES6 semantic + // { let x = 1; } + // { let x; } // x here should be undefined. not 1 + // NOTES: + // Top level bindings never collide with anything and thus don't require explicit initialization. + // As for nested let bindings there are two cases: + // - nested let bindings that were not renamed definitely should be initialized explicitly + // { let x = 1; } + // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } + // Without explicit initialization code in /*1*/ can be executed even if some-condition is evaluated to false + // - renaming introduces fresh name that should not collide with any existing names, however renamed bindings sometimes also should be + // explicitly initialized. One particular case: non-captured binding declared inside loop body (but not in loop initializer) + // let x; + // for (;;) { + // let x; + // } + // in downlevel codegen inner 'x' will be renamed so it won't collide with outer 'x' however it will should be reset on every iteration + // as if it was declared anew. + // * Why non-captured binding - because if loop contains block scoped binding captured in some function then loop body will be rewritten + // to have a fresh scope on every iteration so everything will just work. + // * Why loop initializer is excluded - since we've introduced a fresh name it already will be undefined. + var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(container) || + (isCapturedInFunction && isDeclaredInLoop && container.kind === 196 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false)); + var emittedAsNestedLetDeclaration = ts.getCombinedNodeFlags(node) & 1024 /* Let */ && + !emittedAsTopLevel; + var emitExplicitInitializer = emittedAsNestedLetDeclaration && + container.kind !== 204 /* ForInStatement */ && + container.kind !== 205 /* ForOfStatement */ && + (!resolver.isDeclarationWithCollidingName(node) || + (isDeclaredInLoop && !isCapturedInFunction && !ts.isIterationStatement(container, /*lookInLabeledStatements*/ false))); + if (emitExplicitInitializer) { initializer = createVoidZero(); } } @@ -35008,7 +35943,7 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 190 /* OmittedExpression */) { + if (node.kind === 191 /* OmittedExpression */) { return; } var name = node.name; @@ -35019,20 +35954,14 @@ var ts; ts.forEach(name.elements, emitExportVariableAssignments); } } - function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 214 /* VariableDeclaration */ && node.parent.kind !== 166 /* BindingElement */)) { - return 0; - } - return ts.getCombinedNodeFlags(node.parent); - } function isES6ExportedDeclaration(node) { - return !!(node.flags & 2 /* Export */) && - modulekind === 5 /* ES6 */ && - node.parent.kind === 251 /* SourceFile */; + return !!(node.flags & 1 /* Export */) && + modulekind === ts.ModuleKind.ES6 && + node.parent.kind === 252 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 2 /* Export */) { + if (node.flags & 1 /* Export */) { if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); @@ -35052,14 +35981,14 @@ var ts; write(";"); } } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile) { ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); } } function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { // If we're not exporting the variables, there's nothing special here. // Always emit comments for these nodes. - if (!(node.flags & 2 /* Export */)) { + if (!(node.flags & 1 /* Export */)) { return true; } // If we are exporting, but it's a top-level ES6 module exports, @@ -35100,7 +36029,7 @@ var ts; } function emitDefaultValueAssignments(node) { if (languageVersion < 2 /* ES6 */) { - var tempIndex = 0; + var tempIndex_1 = 0; ts.forEach(node.parameters, function (parameter) { // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. @@ -35117,15 +36046,15 @@ var ts; writeLine(); write("var "); if (hasBindingElements) { - emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex_1]); } else { - emit(tempParameters[tempIndex]); + emit(tempParameters[tempIndex_1]); write(" = "); emit(initializer); } write(";"); - tempIndex++; + tempIndex_1++; } } else if (initializer) { @@ -35189,12 +36118,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 146 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 147 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 177 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 178 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -35205,13 +36134,13 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 176 /* FunctionExpression */) { + if (node.kind === 177 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 216 /* FunctionDeclaration */) { + if (node.kind === 217 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) - return !!node.name || modulekind !== 5 /* ES6 */; + return !!node.name || modulekind !== ts.ModuleKind.ES6; } } function emitFunctionDeclaration(node) { @@ -35221,12 +36150,12 @@ var ts; // TODO (yuisu) : we should not have special cases to condition emitting comments // but have one place to fix check for these conditions. var kind = node.kind, parent = node.parent; - if (kind !== 144 /* MethodDeclaration */ && - kind !== 143 /* MethodSignature */ && + if (kind !== 145 /* MethodDeclaration */ && + kind !== 144 /* MethodSignature */ && parent && - parent.kind !== 248 /* PropertyAssignment */ && - parent.kind !== 171 /* CallExpression */ && - parent.kind !== 167 /* ArrayLiteralExpression */) { + parent.kind !== 249 /* PropertyAssignment */ && + parent.kind !== 172 /* CallExpression */ && + parent.kind !== 168 /* ArrayLiteralExpression */) { // 1. Methods will emit comments at their assignment declaration sites. // // 2. If the function is a property of object literal, emitting leading-comments @@ -35265,11 +36194,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (modulekind !== 5 /* ES6 */ && kind === 216 /* FunctionDeclaration */ && parent === currentSourceFile && node.name) { + if (modulekind !== ts.ModuleKind.ES6 && kind === 217 /* FunctionDeclaration */ && parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } emitEnd(node); - if (kind !== 144 /* MethodDeclaration */ && kind !== 143 /* MethodSignature */) { + if (kind !== 145 /* MethodDeclaration */ && kind !== 144 /* MethodSignature */) { emitTrailingComments(node); } } @@ -35302,8 +36231,8 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 177 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; + var isArrowFunction = node.kind === 178 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -35381,6 +36310,14 @@ var ts; write(" {"); increaseIndent(); writeLine(); + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + writeLines("\nconst _super = (function (geti, seti) {\n const cache = Object.create(null);\n return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });\n})(name => super[name], (name, value) => super[name] = value);"); + writeLine(); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + write("const _super = name => super[name];"); + writeLine(); + } write("return"); } write(" __awaiter(this"); @@ -35390,19 +36327,14 @@ var ts; else { write(", void 0, "); } - if (promiseConstructor) { + if (languageVersion >= 2 /* ES6 */ || !promiseConstructor) { + write("void 0"); + } + else { emitEntityNameAsExpression(promiseConstructor, /*useFallback*/ false); } - else { - write("Promise"); - } // Emit the call to __awaiter. - if (hasLexicalArguments) { - write(", function* (_arguments)"); - } - else { - write(", function* ()"); - } + write(", function* ()"); // Emit the signature and body for the inner generator function. emitFunctionBody(node); write(")"); @@ -35421,7 +36353,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 195 /* Block */) { + if (node.body.kind === 196 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -35480,10 +36412,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 174 /* TypeAssertionExpression */) { + while (current.kind === 175 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 168 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 169 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -35554,23 +36486,27 @@ var ts; } emitToken(16 /* CloseBraceToken */, body.statements.end); } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 198 /* ExpressionStatement */) { - var expr = statement.expression; - if (expr && expr.kind === 171 /* CallExpression */) { - var func = expr.expression; - if (func && func.kind === 95 /* SuperKeyword */) { - return statement; - } - } - } + /** + * Return the statement at a given index if it is a super-call statement + * @param ctor a constructor declaration + * @param index an index to constructor's body to check + */ + function getSuperCallAtGivenIndex(ctor, index) { + if (!ctor.body) { + return undefined; + } + var statements = ctor.body.statements; + if (!statements || index >= statements.length) { + return undefined; + } + var statement = statements[index]; + if (statement.kind === 199 /* ExpressionStatement */) { + return ts.isSuperCallExpression(statement.expression) ? statement : undefined; } } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 56 /* AccessibilityModifier */) { + if (param.flags & 28 /* AccessibilityModifier */) { writeLine(); emitStart(param); emitStart(param.name); @@ -35593,7 +36529,7 @@ var ts; emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 137 /* ComputedPropertyName */) { + else if (memberName.kind === 138 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -35605,7 +36541,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 142 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { + if (member.kind === 143 /* PropertyDeclaration */ && isStatic === ((member.flags & 32 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -35626,7 +36562,7 @@ var ts; emit(receiver); } else { - if (property.flags & 64 /* Static */) { + if (property.flags & 32 /* Static */) { emitDeclarationName(node); } else { @@ -35645,11 +36581,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 194 /* SemicolonClassElement */) { + if (member.kind === 195 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) { + else if (member.kind === 145 /* MethodDeclaration */ || node.kind === 144 /* MethodSignature */) { if (!member.body) { return emitCommentsOnNotEmittedNode(member); } @@ -35666,7 +36602,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 146 /* GetAccessor */ || member.kind === 147 /* SetAccessor */) { + else if (member.kind === 147 /* GetAccessor */ || member.kind === 148 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -35716,22 +36652,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 144 /* MethodDeclaration */ || node.kind === 143 /* MethodSignature */) && !member.body) { + if ((member.kind === 145 /* MethodDeclaration */ || node.kind === 144 /* MethodSignature */) && !member.body) { emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 144 /* MethodDeclaration */ || - member.kind === 146 /* GetAccessor */ || - member.kind === 147 /* SetAccessor */) { + else if (member.kind === 145 /* MethodDeclaration */ || + member.kind === 147 /* GetAccessor */ || + member.kind === 148 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 64 /* Static */) { + if (member.flags & 32 /* Static */) { write("static "); } - if (member.kind === 146 /* GetAccessor */) { + if (member.kind === 147 /* GetAccessor */) { write("get "); } - else if (member.kind === 147 /* SetAccessor */) { + else if (member.kind === 148 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -35742,7 +36678,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 194 /* SemicolonClassElement */) { + else if (member.kind === 195 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -35771,11 +36707,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 145 /* Constructor */ && !member.body) { + if (member.kind === 146 /* Constructor */ && !member.body) { emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 142 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { + if (member.kind === 143 /* PropertyDeclaration */ && member.initializer && (member.flags & 32 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -35829,7 +36765,7 @@ var ts; emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); + superCall = getSuperCallAtGivenIndex(ctor, startIndex); if (superCall) { writeLine(); emit(superCall); @@ -35883,68 +36819,108 @@ var ts; else { emitClassLikeDeclarationForES6AndHigher(node); } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile && node.name) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } } function emitClassLikeDeclarationForES6AndHigher(node) { + var decoratedClassAlias; var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* 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: + // When we emit an ES6 class that has a class decorator, we must tailor the + // emit to certain specific cases. // - // * For a local class declaration: + // In the simplest case, we emit the class declaration as a let declaration, and + // evaluate decorators after the close of the class body: // - // @dec class C { - // } + // TypeScript | Javascript + // --------------------------------|------------------------------------ + // @dec | let C = class C { + // class C { | } + // } | C = __decorate([dec], C); + // --------------------------------|------------------------------------ + // @dec | export let C = class C { + // export class C { | } + // } | C = __decorate([dec], C); + // --------------------------------------------------------------------- + // [Example 1] // - // The emit should be: + // If a class declaration contains a reference to itself *inside* of the class body, + // this introduces two bindings to the class: One outside of the class body, and one + // inside of the class body. If we apply decorators as in [Example 1] above, there + // is the possibility that the decorator `dec` will return a new value for the + // constructor, which would result in the binding inside of the class no longer + // pointing to the same reference as the binding outside of the class. // - // let C = class { - // }; - // C = __decorate([dec], C); + // As a result, we must instead rewrite all references to the class *inside* of the + // class body to instead point to a local temporary alias for the class: // - // * For an exported class declaration: + // TypeScript | Javascript + // --------------------------------|------------------------------------ + // @dec | let C_1; + // class C { | let C = C_1 = class C { + // static x() { return C.y; } | static x() { return C_1.y; } + // static y = 1; | } + // } | C.y = 1; + // | C = C_1 = __decorate([dec], C); + // --------------------------------|------------------------------------ + // @dec | let C_1; + // export class C { | export let C = C_1 = class C { + // static x() { return C.y; } | static x() { return C_1.y; } + // static y = 1; | } + // } | C.y = 1; + // | C = C_1 = __decorate([dec], C); + // --------------------------------------------------------------------- + // [Example 2] // - // @dec export class C { - // } + // If a class declaration is the default export of a module, we instead emit + // the export after the decorated declaration: // - // The emit should be: + // TypeScript | Javascript + // --------------------------------|------------------------------------ + // @dec | let default_1 = class { + // export default class { | } + // } | default_1 = __decorate([dec], default_1); + // | export default default_1; + // --------------------------------|------------------------------------ + // @dec | let C = class C { + // export default class { | } + // } | C = __decorate([dec], C); + // | export default C; + // --------------------------------------------------------------------- + // [Example 3] // - // export let C = class { - // }; - // C = __decorate([dec], C); + // If the class declaration is the default export and a reference to itself + // inside of the class body, we must emit both an alias for the class *and* + // move the export after the declaration: // - // * For a default export of a class declaration with a name: - // - // @dec default export class C { - // } - // - // The emit should be: - // - // let C = class { - // } - // C = __decorate([dec], C); - // export default C; - // - // * For a default export of a class declaration without a name: - // - // @dec default export class { - // } - // - // The emit should be: - // - // let _default = class { - // } - // _default = __decorate([dec], _default); - // export default _default; + // TypeScript | Javascript + // --------------------------------|------------------------------------ + // @dec | let C_1; + // export default class C { | let C = C_1 = class C { + // static x() { return C.y; } | static x() { return C_1.y; } + // static y = 1; | } + // } | C.y = 1; + // | C = C_1 = __decorate([dec], C); + // | export default C; + // --------------------------------------------------------------------- + // [Example 4] // + if (resolver.getNodeCheckFlags(node) & 524288 /* ClassWithBodyScopedClassBinding */) { + decoratedClassAlias = ts.unescapeIdentifier(makeUniqueName(node.name ? node.name.text : "default")); + decoratedClassAliases[ts.getNodeId(node)] = decoratedClassAlias; + write("let " + decoratedClassAlias + ";"); + writeLine(); + } if (isES6ExportedDeclaration(node) && !(node.flags & 512 /* Default */)) { write("export "); } write("let "); emitDeclarationName(node); + if (decoratedClassAlias !== undefined) { + write(" = " + decoratedClassAlias); + } write(" = "); } else if (isES6ExportedDeclaration(node)) { @@ -35966,7 +36942,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, /*isStatic*/ true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 189 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 190 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -35979,7 +36955,7 @@ var ts; // emit name if // - node has a name // - this is default export with static initializers - if ((node.name || (node.flags & 512 /* Default */ && (staticProperties.length > 0 || modulekind !== 5 /* ES6 */))) && !thisNodeIsDecorated) { + if (node.name || (node.flags & 512 /* Default */ && (staticProperties.length > 0 || modulekind !== ts.ModuleKind.ES6) && !thisNodeIsDecorated)) { write(" "); emitDeclarationName(node); } @@ -35996,15 +36972,8 @@ var ts; decreaseIndent(); writeLine(); emitToken(16 /* CloseBraceToken */, node.members.end); - // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. - // For a decorated class, we need to assign its name (if it has one). This is because we emit - // the class as a class expression to avoid the double-binding of the identifier: - // - // let C = class { - // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); - // if (thisNodeIsDecorated) { + decoratedClassAliases[ts.getNodeId(node)] = undefined; write(";"); } // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -36028,12 +36997,12 @@ var ts; else { writeLine(); emitPropertyDeclarations(node, staticProperties); - emitDecoratorsOfClass(node); + emitDecoratorsOfClass(node, decoratedClassAlias); } - if (!(node.flags & 2 /* Export */)) { + if (!(node.flags & 1 /* Export */)) { return; } - if (modulekind !== 5 /* ES6 */) { + if (modulekind !== ts.ModuleKind.ES6) { emitExportMemberAssignment(node); } else { @@ -36048,7 +37017,7 @@ var ts; write(";"); } } - else if (node.parent.kind !== 251 /* SourceFile */) { + else if (node.parent.kind !== 252 /* SourceFile */) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -36060,7 +37029,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -36098,7 +37067,7 @@ var ts; emitMemberFunctionsForES5AndLower(node); emitPropertyDeclarations(node, getInitializedProperties(node, /*isStatic*/ true)); writeLine(); - emitDecoratorsOfClass(node); + emitDecoratorsOfClass(node, /*decoratedClassAlias*/ undefined); writeLine(); emitToken(16 /* CloseBraceToken */, node.members.end, function () { write("return "); @@ -36121,26 +37090,26 @@ var ts; emit(baseTypeNode.expression); } write("))"); - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { emitExportMemberAssignment(node); } } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 64 /* Static */)) { + if (!(member.flags & 32 /* Static */)) { write(".prototype"); } } - function emitDecoratorsOfClass(node) { + function emitDecoratorsOfClass(node, decoratedClassAlias) { emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 64 /* Static */); - emitDecoratorsOfConstructor(node); + emitDecoratorsOfMembers(node, 32 /* Static */); + emitDecoratorsOfConstructor(node, decoratedClassAlias); } - function emitDecoratorsOfConstructor(node) { + function emitDecoratorsOfConstructor(node, decoratedClassAlias) { var decorators = node.decorators; var constructor = ts.getFirstConstructorWithBody(node); var firstParameterDecorator = constructor && ts.forEach(constructor.parameters, function (parameter) { return parameter.decorators; }); @@ -36161,6 +37130,9 @@ var ts; writeLine(); emitStart(node.decorators || firstParameterDecorator); emitDeclarationName(node); + if (decoratedClassAlias !== undefined) { + write(" = " + decoratedClassAlias); + } write(" = __decorate(["); increaseIndent(); writeLine(); @@ -36183,7 +37155,7 @@ var ts; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; // only emit members in the correct group - if ((member.flags & 64 /* Static */) !== staticFlag) { + if ((member.flags & 32 /* Static */) !== staticFlag) { continue; } // skip members that cannot be decorated (such as the constructor) @@ -36209,7 +37181,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 144 /* MethodDeclaration */) { + if (member.kind === 145 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -36266,7 +37238,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); if (languageVersion > 0 /* ES3 */) { - if (member.kind !== 142 /* PropertyDeclaration */) { + if (member.kind !== 143 /* PropertyDeclaration */) { // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. // We have this extra argument here so that we can inject an explicit property descriptor at a later date. write(", null"); @@ -36286,19 +37258,19 @@ var ts; function emitDecoratorsOfParameters(node, leadingComma) { var argumentsWritten = 0; if (node) { - var parameterIndex = 0; + var parameterIndex_1 = 0; for (var _a = 0, _b = node.parameters; _a < _b.length; _a++) { var parameter = _b[_a]; if (ts.nodeIsDecorated(parameter)) { var decorators = parameter.decorators; argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { - write("__param(" + parameterIndex + ", "); + write("__param(" + parameterIndex_1 + ", "); emit(decorator.expression); write(")"); }); leadingComma = true; } - parameterIndex++; + parameterIndex_1++; } } return argumentsWritten; @@ -36308,10 +37280,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 144 /* MethodDeclaration */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 142 /* PropertyDeclaration */: + case 145 /* MethodDeclaration */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 143 /* PropertyDeclaration */: return true; } return false; @@ -36321,7 +37293,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 144 /* MethodDeclaration */: + case 145 /* MethodDeclaration */: return true; } return false; @@ -36331,9 +37303,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 217 /* ClassDeclaration */: - case 144 /* MethodDeclaration */: - case 147 /* SetAccessor */: + case 218 /* ClassDeclaration */: + case 145 /* MethodDeclaration */: + case 148 /* SetAccessor */: return true; } return false; @@ -36351,19 +37323,19 @@ var ts; // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: write("Function"); return; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 139 /* Parameter */: + case 140 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 146 /* GetAccessor */: + case 147 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 147 /* SetAccessor */: + case 148 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -36379,40 +37351,40 @@ var ts; case 103 /* VoidKeyword */: write("void 0"); return; - case 161 /* ParenthesizedType */: + case 162 /* ParenthesizedType */: emitSerializedTypeNode(node.type); return; - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: write("Function"); return; - case 157 /* ArrayType */: - case 158 /* TupleType */: + case 158 /* ArrayType */: + case 159 /* TupleType */: write("Array"); return; - case 151 /* TypePredicate */: + case 152 /* TypePredicate */: case 120 /* BooleanKeyword */: write("Boolean"); return; - case 130 /* StringKeyword */: - case 163 /* StringLiteralType */: + case 131 /* StringKeyword */: + case 164 /* StringLiteralType */: write("String"); return; - case 128 /* NumberKeyword */: + case 129 /* NumberKeyword */: write("Number"); return; - case 131 /* SymbolKeyword */: + case 132 /* SymbolKeyword */: write("Symbol"); return; - case 152 /* TypeReference */: + case 153 /* TypeReference */: emitSerializedTypeReferenceNode(node); return; - case 155 /* TypeQuery */: - case 156 /* TypeLiteral */: - case 159 /* UnionType */: - case 160 /* IntersectionType */: + case 156 /* TypeQuery */: + case 157 /* TypeLiteral */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: case 117 /* AnyKeyword */: - case 162 /* ThisType */: + case 163 /* ThisType */: break; default: ts.Debug.fail("Cannot serialize unexpected type node."); @@ -36484,8 +37456,8 @@ var ts; // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { - var valueDeclaration; - if (node.kind === 217 /* ClassDeclaration */) { + var valueDeclaration = void 0; + if (node.kind === 218 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -36501,10 +37473,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 157 /* ArrayType */) { + if (parameterType.kind === 158 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 152 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 153 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -36581,7 +37553,7 @@ var ts; if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted var isES6ExportedEnum = isES6ExportedDeclaration(node); - if (!(node.flags & 2 /* Export */) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 220 /* EnumDeclaration */))) { + if (!(node.flags & 1 /* Export */) || (isES6ExportedEnum && isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221 /* EnumDeclaration */))) { emitStart(node); if (isES6ExportedEnum) { write("export "); @@ -36610,7 +37582,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 2 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted writeLine(); emitStart(node); @@ -36621,8 +37593,8 @@ var ts; emitEnd(node); write(";"); } - if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { + if (modulekind !== ts.ModuleKind.ES6 && node.parent === currentSourceFile) { + if (modulekind === ts.ModuleKind.System && (node.flags & 1 /* Export */)) { // write the call to exporter for enum writeLine(); write(exportFunctionForFile + "(\""); @@ -36663,7 +37635,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 221 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 222 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -36687,7 +37659,7 @@ var ts; var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); if (emitVarForModule) { var isES6ExportedNamespace = isES6ExportedDeclaration(node); - if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 221 /* ModuleDeclaration */)) { + if (!isES6ExportedNamespace || isFirstDeclarationOfKind(node, node.symbol && node.symbol.declarations, 222 /* ModuleDeclaration */)) { emitStart(node); if (isES6ExportedNamespace) { write("export "); @@ -36705,7 +37677,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 222 /* ModuleBlock */) { + if (node.body.kind === 223 /* ModuleBlock */) { var saveConvertedLoopState = convertedLoopState; var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -36731,7 +37703,7 @@ var ts; } write(")("); // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 2 /* Export */) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -36741,7 +37713,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { + if (modulekind === ts.ModuleKind.System && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -36781,16 +37753,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 224 /* ImportEqualsDeclaration */) { + if (node.kind === 225 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 228 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 225 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 226 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -36799,7 +37771,7 @@ var ts; ts.forEachChild(node, emitExportImportAssignments); } function emitImportDeclaration(node) { - if (modulekind !== 5 /* ES6 */) { + if (modulekind !== ts.ModuleKind.ES6) { return emitExternalImportDeclaration(node); } // ES6 import @@ -36818,7 +37790,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 228 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -36844,16 +37816,19 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 224 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; + var isExportedImport = node.kind === 225 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); - if (modulekind !== 2 /* AMD */) { + var varOrConst = (languageVersion <= 1 /* ES5 */) ? "var " : "const "; + if (modulekind !== ts.ModuleKind.AMD) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { // import x = require("foo") // import * as x from "foo" - if (!isExportedImport) - write("var "); + if (!isExportedImport) { + write(varOrConst); + } + ; emitModuleMemberName(namespaceDeclaration); write(" = "); } @@ -36863,9 +37838,9 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 225 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 226 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { - write("var "); + write(varOrConst); write(getGeneratedNameForNode(node)); write(" = "); } @@ -36892,7 +37867,7 @@ var ts; } else if (namespaceDeclaration && isDefaultImport(node)) { // import d, * as x from "foo" - write("var "); + write(varOrConst); emitModuleMemberName(namespaceDeclaration); write(" = "); write(getGeneratedNameForNode(node)); @@ -36926,7 +37901,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 2 /* Export */)) { + else if (!(node.flags & 1 /* Export */)) { write("var "); } } @@ -36948,14 +37923,14 @@ var ts; } } function emitExportDeclaration(node) { - ts.Debug.assert(modulekind !== 4 /* System */); - if (modulekind !== 5 /* ES6 */) { + ts.Debug.assert(modulekind !== ts.ModuleKind.System); + if (modulekind !== ts.ModuleKind.ES6) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); var generatedName = getGeneratedNameForNode(node); if (node.exportClause) { // export { x, y, ... } from "foo" - if (modulekind !== 2 /* AMD */) { + if (modulekind !== ts.ModuleKind.AMD) { write("var "); write(generatedName); write(" = "); @@ -36984,7 +37959,7 @@ var ts; if (hasExportStarsToExportValues && resolver.moduleExportsSomeValue(node.moduleSpecifier)) { writeLine(); write("__export("); - if (modulekind !== 2 /* AMD */) { + if (modulekind !== ts.ModuleKind.AMD) { emitRequire(ts.getExternalModuleName(node)); } else { @@ -37017,7 +37992,7 @@ var ts; } } function emitExportOrImportSpecifierList(specifiers, shouldEmit) { - ts.Debug.assert(modulekind === 5 /* ES6 */); + ts.Debug.assert(modulekind === ts.ModuleKind.ES6); var needsComma = false; for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { var specifier = specifiers_1[_a]; @@ -37036,14 +38011,14 @@ var ts; } function emitExportAssignment(node) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (modulekind === 5 /* ES6 */) { + if (modulekind === ts.ModuleKind.ES6) { writeLine(); emitStart(node); write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 216 /* FunctionDeclaration */ && - expression.kind !== 217 /* ClassDeclaration */) { + if (expression.kind !== 217 /* FunctionDeclaration */ && + expression.kind !== 218 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -37051,7 +38026,7 @@ var ts; else { writeLine(); emitStart(node); - if (modulekind === 4 /* System */) { + if (modulekind === ts.ModuleKind.System) { write(exportFunctionForFile + "(\"default\","); emit(node.expression); write(")"); @@ -37080,7 +38055,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" @@ -37090,13 +38065,13 @@ var ts; externalImports.push(node); } break; - case 224 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 235 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 225 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 236 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -37119,7 +38094,7 @@ var ts; } } break; - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -37145,10 +38120,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getTextOfNodeFromSourceText(currentText, namespaceDeclaration.name); } - if (node.kind === 225 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 226 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 231 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 232 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -37174,8 +38149,8 @@ var ts; for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { var importNode = externalImports_1[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 231 /* ExportDeclaration */ || - (importNode.kind === 225 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 232 /* ExportDeclaration */ || + (importNode.kind === 226 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -37196,7 +38171,7 @@ var ts; // when resolving exports local exported entries/indirect exported entries in the module // should always win over entries with similar names that were added via star exports // to support this we store names of local/indirect exported entries in a set. - // this set is used to filter names brought by star expors. + // this set is used to filter names brought by star exports. if (!hasExportStarsToExportValues) { // local names set is needed only in presence of star exports return undefined; @@ -37208,7 +38183,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { var externalImport = externalImports_2[_a]; - if (externalImport.kind === 231 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 232 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -37240,7 +38215,7 @@ var ts; } for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { var externalImport = externalImports_3[_d]; - if (externalImport.kind !== 231 /* ExportDeclaration */) { + if (externalImport.kind !== 232 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -37344,14 +38319,14 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 217 /* ClassDeclaration */ || local.kind === 221 /* ModuleDeclaration */ || local.kind === 220 /* EnumDeclaration */) { + if (local.kind === 218 /* ClassDeclaration */ || local.kind === 222 /* ModuleDeclaration */ || local.kind === 221 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); - if (flags & 2 /* Export */) { + if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -37365,7 +38340,7 @@ var ts; var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 2 /* Export */) { + if (f.flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -37375,24 +38350,24 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 4 /* Ambient */) { + if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 216 /* FunctionDeclaration */) { + if (node.kind === 217 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 217 /* ClassDeclaration */) { + if (node.kind === 218 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 220 /* EnumDeclaration */) { + if (node.kind === 221 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -37401,7 +38376,7 @@ var ts; } return; } - if (node.kind === 221 /* ModuleDeclaration */) { + if (node.kind === 222 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -37410,7 +38385,7 @@ var ts; } return; } - if (node.kind === 214 /* VariableDeclaration */ || node.kind === 166 /* BindingElement */) { + if (node.kind === 215 /* VariableDeclaration */ || node.kind === 167 /* BindingElement */) { if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_30 = node.name; if (name_30.kind === 69 /* Identifier */) { @@ -37450,11 +38425,11 @@ var ts; // - it is top level block scoped // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 251 /* SourceFile */; + return (ts.getCombinedNodeFlags(node) & 3072 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 252 /* SourceFile */; } function isCurrentFileSystemExternalModule() { - return modulekind === 4 /* System */ && isCurrentFileExternalModule; + return modulekind === ts.ModuleKind.System && isCurrentFileExternalModule; } function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: @@ -37526,21 +38501,21 @@ var ts; var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // fall-through - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); break; - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -37599,10 +38574,10 @@ var ts; // - import declarations are not emitted since they are already handled in setters // - export declarations with module specifiers are not emitted since they were already written in setters // - export declarations without module specifiers are emitted preserving the order - case 216 /* FunctionDeclaration */: - case 225 /* ImportDeclaration */: + case 217 /* FunctionDeclaration */: + case 226 /* ImportDeclaration */: continue; - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: if (!statement.moduleSpecifier) { for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { var element = _b[_a]; @@ -37611,7 +38586,7 @@ var ts; } } continue; - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { // - import equals declarations that import external modules are not emitted continue; @@ -37645,6 +38620,7 @@ var ts; ts.Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); + contextObjectForFile = makeUniqueName("context"); writeLine(); write("System.register("); writeModuleName(node, emitRelativePathAsModuleName); @@ -37653,14 +38629,20 @@ var ts; var dependencyGroups = []; for (var i = 0; i < externalImports.length; i++) { var text = getExternalModuleNameText(externalImports[i], emitRelativePathAsModuleName); - if (ts.hasProperty(groupIndices, text)) { + if (text === undefined) { + continue; + } + // text should be quoted string + // for deduplication purposes in key remove leading and trailing quotes so 'a' and "a" will be considered the same + var key = text.substr(1, text.length - 2); + if (ts.hasProperty(groupIndices, key)) { // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; + var groupIndex = groupIndices[key]; dependencyGroups[groupIndex].push(externalImports[i]); continue; } else { - groupIndices[text] = dependencyGroups.length; + groupIndices[key] = dependencyGroups.length; dependencyGroups.push([externalImports[i]]); } if (i !== 0) { @@ -37668,10 +38650,13 @@ var ts; } write(text); } - write("], function(" + exportFunctionForFile + ") {"); + write("], function(" + exportFunctionForFile + ", " + contextObjectForFile + ") {"); writeLine(); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); + writeLine(); + write("var __moduleName = " + contextObjectForFile + " && " + contextObjectForFile + ".id;"); + writeLine(); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -37761,7 +38746,7 @@ var ts; writeModuleName(node, emitRelativePathAsModuleName); emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -37772,7 +38757,7 @@ var ts; write("});"); } function emitCommonJSModule(node) { - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ true); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -37792,7 +38777,7 @@ var ts; writeLines(" }\n})("); emitAMDFactoryHeader(dependencyNames); increaseIndent(); - var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -37880,6 +38865,18 @@ var ts; } return result; } + function isJsxChildEmittable(child) { + if (child.kind === 244 /* JsxExpression */) { + // Don't emit empty expressions + return !!child.expression; + } + else if (child.kind === 240 /* JsxText */) { + // Don't emit empty strings + return !!getTextToEmit(child); + } + return true; + } + ; function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2 /* React */: @@ -37970,22 +38967,22 @@ var ts; if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 4194304 /* HasClassExtends */)) { + if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 262144 /* HasClassExtends */)) { writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && node.flags & 8388608 /* HasDecorators */) { + if (!decorateEmitted && node.flags & 524288 /* HasDecorators */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && node.flags & 16777216 /* HasParamDecorators */) { + if (!paramEmitted && node.flags & 1048576 /* HasParamDecorators */) { writeLines(paramHelper); paramEmitted = true; } - if (!awaiterEmitted && node.flags & 33554432 /* HasAsyncFunctions */) { + if (!awaiterEmitted && node.flags & 2097152 /* HasAsyncFunctions */) { writeLines(awaiterHelper); awaiterEmitted = true; } @@ -37998,7 +38995,7 @@ var ts; emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (isOwnFileEmit || (!ts.isExternalModule(node) && compilerOptions.isolatedModules)) { - var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; + var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ts.ModuleKind.CommonJS]; emitModule(node); } else { @@ -38027,7 +39024,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 4 /* Ambient */) { + if (node.flags & 2 /* Ambient */) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -38073,24 +39070,24 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: - case 225 /* ImportDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 230 /* ExportAssignment */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: + case 226 /* ImportDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 231 /* ExportAssignment */: return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); @@ -38102,9 +39099,9 @@ var ts; // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 195 /* Block */ && + if (node.kind !== 196 /* Block */ && node.parent && - node.parent.kind === 177 /* ArrowFunction */ && + node.parent.kind === 178 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -38117,13 +39114,13 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return emitIdentifier(node); - case 139 /* Parameter */: + case 140 /* Parameter */: return emitParameter(node); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return emitMethod(node); - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: return emitAccessor(node); case 97 /* ThisKeyword */: return emitThis(node); @@ -38143,142 +39140,142 @@ var ts; case 13 /* TemplateMiddle */: case 14 /* TemplateTail */: return emitLiteral(node); - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: return emitTemplateExpression(node); - case 193 /* TemplateSpan */: + case 194 /* TemplateSpan */: return emitTemplateSpan(node); - case 236 /* JsxElement */: - case 237 /* JsxSelfClosingElement */: + case 237 /* JsxElement */: + case 238 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 239 /* JsxText */: + case 240 /* JsxText */: return emitJsxText(node); - case 243 /* JsxExpression */: + case 244 /* JsxExpression */: return emitJsxExpression(node); - case 136 /* QualifiedName */: + case 137 /* QualifiedName */: return emitQualifiedName(node); - case 164 /* ObjectBindingPattern */: + case 165 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 165 /* ArrayBindingPattern */: + case 166 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 166 /* BindingElement */: + case 167 /* BindingElement */: return emitBindingElement(node); - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 248 /* PropertyAssignment */: + case 249 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 249 /* ShorthandPropertyAssignment */: + case 250 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 137 /* ComputedPropertyName */: + case 138 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 169 /* PropertyAccessExpression */: + case 170 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 170 /* ElementAccessExpression */: + case 171 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 171 /* CallExpression */: + case 172 /* CallExpression */: return emitCallExpression(node); - case 172 /* NewExpression */: + case 173 /* NewExpression */: return emitNewExpression(node); - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 174 /* TypeAssertionExpression */: + case 175 /* TypeAssertionExpression */: return emit(node.expression); - case 192 /* AsExpression */: + case 193 /* AsExpression */: return emit(node.expression); - case 175 /* ParenthesizedExpression */: + case 176 /* ParenthesizedExpression */: return emitParenExpression(node); - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 178 /* DeleteExpression */: + case 179 /* DeleteExpression */: return emitDeleteExpression(node); - case 179 /* TypeOfExpression */: + case 180 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 180 /* VoidExpression */: + case 181 /* VoidExpression */: return emitVoidExpression(node); - case 181 /* AwaitExpression */: + case 182 /* AwaitExpression */: return emitAwaitExpression(node); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 183 /* PostfixUnaryExpression */: + case 184 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return emitBinaryExpression(node); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return emitConditionalExpression(node); - case 188 /* SpreadElementExpression */: + case 189 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 187 /* YieldExpression */: + case 188 /* YieldExpression */: return emitYieldExpression(node); - case 190 /* OmittedExpression */: + case 191 /* OmittedExpression */: return; - case 195 /* Block */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return emitBlock(node); - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: return emitVariableStatement(node); - case 197 /* EmptyStatement */: + case 198 /* EmptyStatement */: return write(";"); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: return emitExpressionStatement(node); - case 199 /* IfStatement */: + case 200 /* IfStatement */: return emitIfStatement(node); - case 200 /* DoStatement */: + case 201 /* DoStatement */: return emitDoStatement(node); - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: return emitWhileStatement(node); - case 202 /* ForStatement */: + case 203 /* ForStatement */: return emitForStatement(node); - case 204 /* ForOfStatement */: - case 203 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 204 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 205 /* ContinueStatement */: - case 206 /* BreakStatement */: + case 206 /* ContinueStatement */: + case 207 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: return emitReturnStatement(node); - case 208 /* WithStatement */: + case 209 /* WithStatement */: return emitWithStatement(node); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: return emitSwitchStatement(node); - case 244 /* CaseClause */: - case 245 /* DefaultClause */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: return emitLabeledStatement(node); - case 211 /* ThrowStatement */: + case 212 /* ThrowStatement */: return emitThrowStatement(node); - case 212 /* TryStatement */: + case 213 /* TryStatement */: return emitTryStatement(node); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return emitCatchClause(node); - case 213 /* DebuggerStatement */: + case 214 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 214 /* VariableDeclaration */: + case 215 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: return emitClassExpression(node); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: return emitClassDeclaration(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return emitEnumMember(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: return emitImportDeclaration(node); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: return emitExportDeclaration(node); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: return emitExportAssignment(node); - case 251 /* SourceFile */: + case 252 /* SourceFile */: return emitSourceFileNode(node); } } @@ -38317,7 +39314,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 === 251 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 252 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -38332,7 +39329,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 251 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 252 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentText, node.end); } } @@ -38362,7 +39359,7 @@ var ts; // declare var x; // /// // interface F {} - // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted if (node.pos === 0) { leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); } @@ -38462,7 +39459,7 @@ var ts; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ var emptyArray = []; - ts.version = "1.8.0"; + ts.version = "1.9.0"; function findConfigFile(searchPath, fileExists) { var fileName = "tsconfig.json"; while (true) { @@ -38485,36 +39482,315 @@ var ts; 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, compilerOptions, host); - case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + function trace(host, message) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceModuleResolution && host.trace !== undefined; + } + function startsWith(str, prefix) { + return str.lastIndexOf(prefix, 0) === 0; + } + function endsWith(str, suffix) { + var expectedPos = str.length - suffix.length; + return str.indexOf(suffix, expectedPos) === expectedPos; + } + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42 /* asterisk */) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + // have already seen asterisk + return false; + } + } } + return true; + } + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + } + function moduleHasNonRelativeName(moduleName) { + if (ts.isRootedDiskPath(moduleName)) { + return false; + } + var i = moduleName.lastIndexOf("./", 1); + var startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === 46 /* dot */); + return !startsWithDotSlashOrDotDotSlash; + } + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; } ts.resolveModuleName = resolveModuleName; + /** + * Any module resolution kind can be augmented with optional settings: 'baseUrl', 'paths' and 'rootDirs' - they are used to + * mitigate differences between design time structure of the project and its runtime counterpart so the same import name + * can be resolved successfully by TypeScript compiler and runtime module loader. + * If these settings are set then loading procedure will try to use them to resolve module name and it can of failure it will + * fallback to standard resolution routine. + * + * - baseUrl - this setting controls how non-relative module names are resolved. If this setting is specified then non-relative + * names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then candidate location to resolve module name 'c/d' will + * be '/a/b/c/d' + * - paths - this setting can only be used when baseUrl is specified. allows to tune how non-relative module names + * will be resolved based on the content of the module name. + * Structure of 'paths' compiler options + * 'paths': { + * pattern-1: [...substitutions], + * pattern-2: [...substitutions], + * ... + * pattern-n: [...substitutions] + * } + * Pattern here is a string that can contain zero or one '*' character. During module resolution module name will be matched against + * all patterns in the list. Matching for patterns that don't contain '*' means that module name must be equal to pattern respecting the case. + * If pattern contains '*' then to match pattern "*" module name must start with the and end with . + * denotes part of the module name between and . + * If module name can be matches with multiple patterns then pattern with the longest prefix will be picked. + * After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module + * from the candidate location. + * Substitution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every + * substitution in the list and replace '*' with string. If candidate location is not rooted it + * will be converted to absolute using baseUrl. + * For example: + * baseUrl: /a/b/c + * "paths": { + * // match all module names + * "*": [ + * "*", // use matched name as is, + * // will be looked as /a/b/c/ + * + * "folder1/*" // substitution will convert matched name to 'folder1/', + * // since it is not rooted then final candidate location will be /a/b/c/folder1/ + * ], + * // match module names that start with 'components/' + * "components/*": [ "/root/components/*" ] // substitution will convert /components/folder1/ to '/root/components/folder1/', + * // it is rooted so it will be final candidate location + * } + * + * 'rootDirs' allows the project to be spreaded across multiple locations and resolve modules with relative names as if + * they were in the same location. For example lets say there are two files + * '/local/src/content/file1.ts' + * '/shared/components/contracts/src/content/protocols/file2.ts' + * After bundling content of '/shared/components/contracts/src' will be merged with '/local/src' so + * if file1 has the following import 'import {x} from "./protocols/file2"' it will be resolved successfully in runtime. + * 'rootDirs' provides the way to tell compiler that in order to get the whole project it should behave as if content of all + * root dirs were merged together. + * I.e. for the example above 'rootDirs' will have two entries: [ '/local/src', '/shared/components/contracts/src' ]. + * Compiler will first convert './protocols/file2' into absolute path relative to the location of containing file: + * '/local/src/content/protocols/file2' and try to load it - failure. + * Then it will search 'rootDirs' looking for a longest matching prefix of this absolute path and if such prefix is found - absolute path will + * be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining + * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. + */ + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } + } + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + // rootDirs are expected to be absolute + // in case of tsconfig.json this will happen automatically - compiler will expand relative names + // using location of tsconfig.json as base location + var normalizedRoot = ts.normalizePath(rootDir); + if (!endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + // first - try to load from a initial location + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + // then try to resolve using remaining entries in rootDirs + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + // skip the initially matched entry + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var longestMatchPrefixLength = -1; + var matchedPattern; + var matchedStar; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + for (var key in state.compilerOptions.paths) { + var pattern = key; + var indexOfStar = pattern.indexOf("*"); + if (indexOfStar !== -1) { + var prefix = pattern.substr(0, indexOfStar); + var suffix = pattern.substr(indexOfStar + 1); + if (moduleName.length >= prefix.length + suffix.length && + startsWith(moduleName, prefix) && + endsWith(moduleName, suffix)) { + // use length of prefix as betterness criteria + if (prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = prefix.length; + matchedPattern = pattern; + matchedStar = moduleName.substr(prefix.length, moduleName.length - suffix.length); + } + } + } + else if (pattern === moduleName) { + // pattern was matched as is - no need to search further + matchedPattern = pattern; + matchedStar = undefined; + break; + } + } + } + if (matchedPattern) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPattern); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPattern]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("\*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { - var failedLookupLocations = []; - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var resolvedFileName = loadNodeModuleFromFile(supportedExtensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, host); - if (resolvedFileName) { - return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); + } + var isExternalLibraryImport = false; + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, host); - return resolvedFileName - ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state); + isExternalLibraryImport = resolvedFileName !== undefined; } else { - return loadModuleFromNodeModules(moduleName, containingDirectory, host); + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + } /* @internal */ function directoryProbablyExists(directoryName, host) { // if host does not support 'directoryExists' assume that directory will exist @@ -38525,63 +39801,90 @@ var ts; * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ - function loadNodeModuleFromFile(extensions, candidate, failedLookupLocation, onlyRecordFailures, host) { + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { return ts.forEach(extensions, tryLoad); function tryLoad(ext) { + if (ext === ".tsx" && state.skipTsx) { + return undefined; + } var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (!onlyRecordFailures && host.fileExists(fileName)) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_module_resolution_result, fileName); + } return fileName; } else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } failedLookupLocation.push(fileName); return undefined; } } } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, host) { + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { var packageJsonPath = ts.combinePaths(candidate, "package.json"); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, host); - if (directoryExists && host.fileExists(packageJsonPath)) { - var jsonContent; + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var jsonContent = void 0; try { - var jsonText = host.readFile(packageJsonPath); + var jsonText = state.host.readFile(packageJsonPath); jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; } catch (e) { - // gracefully handle if readFile fails or returns not JSON + // gracefully handle if readFile fails or returns not JSON jsonContent = { typings: undefined }; } - if (typeof jsonContent.typings === "string") { - var path = ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)); - var result = loadNodeModuleFromFile(extensions, path, failedLookupLocation, !directoryProbablyExists(ts.getDirectoryPath(path), host), host); - if (result) { - return result; + if (jsonContent.typings) { + if (typeof jsonContent.typings === "string") { + var typingsFile = ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_typings_field_0_that_references_1, jsonContent.typings, typingsFile); + } + var result = loadModuleFromFile(typingsFile, extensions, failedLookupLocation, !directoryProbablyExists(ts.getDirectoryPath(typingsFile), state.host), state); + if (result) { + return result; + } + } + else if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_typings_field_in_package_json_to_be_string_got_0, typeof jsonContent.typings); + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_typings_field); } } } else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results failedLookupLocation.push(packageJsonPath); } - return loadNodeModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, host); + return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); } - function loadModuleFromNodeModules(moduleName, directory, host) { - var failedLookupLocations = []; + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state) { directory = ts.normalizeSlashes(directory); while (true) { var baseName = ts.getBaseFileName(directory); if (baseName !== "node_modules") { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, host); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); // Load only typescript files irrespective of allowJs option if loading from node modules - var result = loadNodeModuleFromFile(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host); + var result = loadModuleFromFile(candidate, ts.supportedTypeScriptExtensions, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + return result; } - result = loadNodeModuleFromDirectory(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host); + result = loadNodeModuleFromDirectory(ts.supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); if (result) { - return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + return result; } } var parentPath = ts.getDirectoryPath(directory); @@ -38590,46 +39893,36 @@ var ts; } directory = parentPath; } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - function nameStartsWithDotSlashOrDotDotSlash(name) { - var i = name.lastIndexOf("./", 1); - return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + return undefined; } 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 { resolvedModule: undefined, failedLookupLocations: [] }; - } - var searchPath = ts.getDirectoryPath(containingFile); - var searchName; + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; var failedLookupLocations = []; - var referencedSourceFile; var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - referencedSourceFile = ts.forEach(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 containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); + } + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + if (referencedSourceFile) { + break; } - var candidate = searchName + extension; - if (host.fileExists(candidate)) { - return candidate; + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + break; } - else { - failedLookupLocations.push(candidate); - } - }); - if (referencedSourceFile) { - break; + containingDirectory = parentPath; } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); } return referencedSourceFile ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } @@ -38638,7 +39931,7 @@ var ts; ts.classicNameResolver = classicNameResolver; /* @internal */ ts.defaultInitCompilerOptions = { - module: 1 /* CommonJS */, + module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, noImplicitAny: false, sourceMap: false @@ -38710,6 +40003,7 @@ var ts; getNewLine: function () { return newLine; }, fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, readFile: function (fileName) { return ts.sys.readFile(fileName); }, + trace: function (s) { return ts.sys.write(s + newLine); }, directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); } }; } @@ -38784,7 +40078,7 @@ var ts; }); var filesByName = ts.createFileMap(); // stores 'filename -> file association' ignoring case - // used to track cases when two file names differ only in casing + // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (oldProgram) { // check properties that can affect structure of the program or module resolution strategy @@ -38977,13 +40271,20 @@ var ts; return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + var declarationDiagnostics = []; + if (options.noEmit) { + return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true }; + } // 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) { - var preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken); - if (preEmitDiagnostics.length > 0) { - return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true }; + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (diagnostics.length === 0 && program.getCompilerOptions().declaration) { + declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); + } + if (diagnostics.length > 0 || declarationDiagnostics.length > 0) { + return { diagnostics: diagnostics, sourceMaps: undefined, emitSkipped: true }; } } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -39037,7 +40338,7 @@ var ts; // We were canceled while performing the operation. Because our type checker // might be a bad state, we need to throw it away. // - // Note: we are overly agressive here. We do not actually *have* to throw away + // Note: we are overly aggressive here. We do not actually *have* to throw away // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep // the lifetimes of these two TypeCheckers the same. Also, we generally only // cancel when the user has made a change anyways. And, in that case, we (the @@ -39075,44 +40376,47 @@ var ts; return false; } switch (node.kind) { - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 230 /* ExportAssignment */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - case 217 /* ClassDeclaration */: + case 231 /* ExportAssignment */: + if (node.isExportEquals) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 218 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 246 /* HeritageClause */: + case 247 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 106 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: - case 216 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -39120,20 +40424,20 @@ var ts; return true; } break; - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 214 /* VariableDeclaration */: + case 215 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start_2 = expression.typeArguments.pos; @@ -39141,7 +40445,7 @@ var ts; return true; } break; - case 139 /* Parameter */: + case 140 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start_3 = parameter.modifiers.pos; @@ -39157,18 +40461,20 @@ var ts; return true; } break; - case 142 /* PropertyDeclaration */: + case 143 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 174 /* TypeAssertionExpression */: + case 175 /* 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 140 /* Decorator */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); + case 141 /* Decorator */: + if (!options.experimentalDecorators) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + } return true; } return ts.forEachChild(node, walk); @@ -39196,6 +40502,7 @@ var ts; case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: + case 127 /* ReadonlyKeyword */: case 122 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; @@ -39268,9 +40575,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 225 /* ImportDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 231 /* ExportDeclaration */: + case 226 /* ImportDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 232 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -39279,14 +40586,14 @@ var ts; break; } // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules + // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules // only through top - level external module names. Relative external module names are not permitted. if (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { (imports || (imports = [])).push(moduleNameExpr); } break; - case 221 /* ModuleDeclaration */: - if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { + case 222 /* ModuleDeclaration */: + if (ts.isAmbientModule(node) && (inAmbientModule || node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. // This will happen in two cases: @@ -39297,7 +40604,7 @@ var ts; (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); } else if (!inAmbientModule) { - // An AmbientExternalModuleDeclaration declares an external module. + // 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 @@ -39311,7 +40618,7 @@ var ts; } } function collectRequireCalls(node) { - if (ts.isRequireCall(node)) { + if (ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { (imports || (imports = [])).push(node.arguments[0]); } else { @@ -39435,7 +40742,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); // add file to program only if: - // - resolution was successfull + // - resolution was successful // - noResolve is falsy // - module name come from the list fo imports var shouldAddFile = resolution && @@ -39446,7 +40753,7 @@ var ts; if (importedFile && resolution.isExternalLibraryImport) { // Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files, // this check is ok. Otherwise this would be never true for javascript file - if (!ts.isExternalModule(importedFile)) { + if (!ts.isExternalModule(importedFile) && importedFile.statements.length) { var start_5 = ts.getTokenPosOfNode(file.imports[i], file); fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_5, file.imports[i].end - start_5, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName)); } @@ -39543,6 +40850,25 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } } + if (options.paths && options.baseUrl === undefined) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option)); + } + if (options.paths) { + for (var key in options.paths) { + if (!ts.hasProperty(options.paths, key)) { + continue; + } + if (!hasZeroOrOneAsteriskCharacter(key)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); + } + for (var _i = 0, _a = options.paths[key]; _i < _a.length; _i++) { + var subst = _a[_i]; + if (!hasZeroOrOneAsteriskCharacter(subst)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); + } + } + } + } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); @@ -39567,7 +40893,7 @@ var ts; 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 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES6 */) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -39576,17 +40902,17 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { + else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file)); } // Cannot specify module gen target of es6 when below es6 - if (options.module === 5 /* ES6 */ && languageVersion < 2 /* ES6 */) { + if (options.module === ts.ModuleKind.ES6 && languageVersion < 2 /* ES6 */) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower)); } // Cannot specify module gen that isn't amd or system with --out - if (outFile && options.module && !(options.module === 2 /* AMD */ || options.module === 4 /* System */)) { + if (outFile && options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); } // there has to be common source directory if user specified --outdir || --sourceRoot @@ -39623,15 +40949,15 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.reactNamespace && !ts.isIdentifier(options.reactNamespace, languageVersion)) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalide_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); } // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files - if (!options.noEmit) { + if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); - var emitFilesSeen = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); + var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { - verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen); - verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen); + verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); + verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); } // Verify that all the emit files are unique and don't overwrite input files @@ -39740,16 +41066,17 @@ var ts; name: "module", shortName: "m", type: { - "commonjs": 1 /* CommonJS */, - "amd": 2 /* AMD */, - "system": 4 /* System */, - "umd": 3 /* UMD */, - "es6": 5 /* ES6 */, - "es2015": 5 /* ES2015 */ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES6, + "es2015": ts.ModuleKind.ES2015 }, description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es2015 + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_es2015_or_none }, { name: "newLine", @@ -39916,8 +41243,8 @@ var ts; { name: "moduleResolution", type: { - "node": 2 /* NodeJs */, - "classic": 1 /* Classic */ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic }, description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic @@ -39948,14 +41275,45 @@ var ts; description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { - name: "allowSyntheticDefaultImports", + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "rootDirs", + type: "object", + isTSConfigOnly: true, + isFilePath: true + }, + { + name: "traceModuleResolution", type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + description: ts.Diagnostics.Enable_tracing_of_the_module_resolution_process }, { name: "allowJs", type: "boolean", description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output } ]; var optionNameMapCache; @@ -40003,33 +41361,38 @@ var ts; } if (ts.hasProperty(optionNameMap, s)) { var opt = optionNameMap[s]; - // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - // If not a primitive, the possible types are specified in what is effectively a map of options. - default: - var map_1 = opt.type; - var key = (args[i] || "").toLowerCase(); - i++; - if (ts.hasProperty(map_1, key)) { - options[opt.name] = map_1[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - } + else { + // Check to see if no argument was provided (e.g. "--locale" is the last command-line argument). + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + var map_1 = opt.type; + var key = (args[i] || "").toLowerCase(); + i++; + if (ts.hasProperty(map_1, key)) { + options[opt.name] = map_1[key]; + } + else { + errors.push(ts.createCompilerDiagnostic(opt.error)); + } + } } } else { @@ -40138,9 +41501,9 @@ var ts; * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json, host, basePath, existingOptions) { + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName) { if (existingOptions === void 0) { existingOptions = {}; } - var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), optionsFromJsonConfigFile = _a.options, errors = _a.errors; + var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath, configFileName), optionsFromJsonConfigFile = _a.options, errors = _a.errors; var options = ts.extend(existingOptions, optionsFromJsonConfigFile); return { options: options, @@ -40159,7 +41522,19 @@ var ts; } else { var filesSeen = {}; - var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; + var exclude = []; + if (json["exclude"] instanceof Array) { + exclude = json["exclude"]; + } + else { + // by default exclude node_modules, and any specificied output directory + exclude = ["node_modules"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + exclude.push(outDir); + } + } + exclude = ts.map(exclude, ts.normalizeSlashes); var supportedExtensions = ts.getSupportedExtensions(options); ts.Debug.assert(ts.indexOf(supportedExtensions, ".ts") < ts.indexOf(supportedExtensions, ".d.ts"), "Changed priority of extensions to pick"); // Get files of supported extensions in their order of resolution @@ -40168,11 +41543,15 @@ var ts; var filesInDirWithExtension = host.readDirectory(basePath, extension, exclude); for (var _a = 0, filesInDirWithExtension_1 = filesInDirWithExtension; _a < filesInDirWithExtension_1.length; _a++) { var fileName = filesInDirWithExtension_1[_a]; - // .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension, + // .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension, // lets pick them when its turn comes up if (extension === ".ts" && ts.fileExtensionIs(fileName, ".d.ts")) { continue; } + // Skip over any minified JavaScript files (ending in ".min.js") + if (/\.min\.js$/.test(fileName)) { + continue; + } // If this is one of the output extension (which would be .d.ts and .js if we are allowing compilation of js files) // do not include this file if we included .ts or .tsx file with same base name as it could be output of the earlier compilation if (extension === ".d.ts" || (options.allowJs && ts.contains(ts.supportedJavascriptExtensions, extension))) { @@ -40190,9 +41569,12 @@ var ts; } } ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompilerOptionsFromJson(jsonOptions, basePath) { + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var options = {}; var errors = []; + if (configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json") { + options.allowJs = true; + } if (!jsonOptions) { return { options: options, errors: errors }; } @@ -40215,7 +41597,37 @@ var ts; } } if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + switch (typeof value) { + case "string": + value = ts.normalizePath(ts.combinePaths(basePath, value)); + break; + case "object": + // "object" options with 'isFilePath' = true expected to be string arrays + var paths = []; + var invalidOptionType = false; + if (!ts.isArray(value)) { + invalidOptionType = true; + } + else { + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + if (typeof element === "string") { + paths.push(ts.normalizePath(ts.combinePaths(basePath, element))); + } + else { + invalidOptionType = true; + break; + } + } + } + if (invalidOptionType) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_should_have_array_of_strings_as_a_value, opt.name)); + } + else { + value = paths; + } + break; + } if (value === "") { value = "."; } @@ -40306,7 +41718,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 177 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 178 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -40318,30 +41730,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 195 /* Block */: + case 196 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; + var parent_9 = 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 === 200 /* DoStatement */ || - parent_8.kind === 203 /* ForInStatement */ || - parent_8.kind === 204 /* ForOfStatement */ || - parent_8.kind === 202 /* ForStatement */ || - parent_8.kind === 199 /* IfStatement */ || - parent_8.kind === 201 /* WhileStatement */ || - parent_8.kind === 208 /* WithStatement */ || - parent_8.kind === 247 /* CatchClause */) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + if (parent_9.kind === 201 /* DoStatement */ || + parent_9.kind === 204 /* ForInStatement */ || + parent_9.kind === 205 /* ForOfStatement */ || + parent_9.kind === 203 /* ForStatement */ || + parent_9.kind === 200 /* IfStatement */ || + parent_9.kind === 202 /* WhileStatement */ || + parent_9.kind === 209 /* WithStatement */ || + parent_9.kind === 248 /* CatchClause */) { + addOutliningSpan(parent_9, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 212 /* TryStatement */) { + if (parent_9.kind === 213 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_8; + var tryStatement = parent_9; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_9, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -40364,23 +41776,23 @@ var ts; break; } // Fallthrough. - case 222 /* ModuleBlock */: { + case 223 /* 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 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 168 /* ObjectLiteralExpression */: - case 223 /* CaseBlock */: { + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 169 /* ObjectLiteralExpression */: + case 224 /* 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 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -40419,8 +41831,8 @@ var ts; if (!matches) { continue; } - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { @@ -40473,7 +41885,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 137 /* ComputedPropertyName */) { + else if (declaration.name.kind === 138 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -40494,7 +41906,7 @@ var ts; } return true; } - if (expression.kind === 169 /* PropertyAccessExpression */) { + if (expression.kind === 170 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -40507,7 +41919,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 137 /* ComputedPropertyName */) { + if (declaration.name.kind === 138 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -40581,17 +41993,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 221 /* ModuleDeclaration */: + case 222 /* 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 === 221 /* ModuleDeclaration */); + } while (current.kind === 222 /* ModuleDeclaration */); // fall through - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -40602,21 +42014,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 231 /* ExportDeclaration */: + case 232 /* 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 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -40628,7 +42040,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 228 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -40637,21 +42049,21 @@ var ts; } } break; - case 166 /* BindingElement */: - case 214 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 215 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 218 /* InterfaceDeclaration */: - case 221 /* ModuleDeclaration */: - case 216 /* FunctionDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 229 /* ImportSpecifier */: - case 233 /* ExportSpecifier */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 219 /* InterfaceDeclaration */: + case 222 /* ModuleDeclaration */: + case 217 /* FunctionDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 230 /* ImportSpecifier */: + case 234 /* ExportSpecifier */: childNodes.push(node); break; } @@ -40699,17 +42111,17 @@ var ts; for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; switch (node.kind) { - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 219 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -40720,12 +42132,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 216 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 217 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 195 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 196 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 216 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 217 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -40785,44 +42197,44 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 139 /* Parameter */: + case 140 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 1022 /* Modifier */) === 0) { + if ((node.flags & 959 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 146 /* GetAccessor */: + case 147 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 147 /* SetAccessor */: + case 148 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 250 /* EnumMember */: + case 251 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 148 /* CallSignature */: + case 149 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 149 /* ConstructSignature */: + case 150 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: - var variableDeclarationNode; + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: + var variableDeclarationNode = void 0; var name_32; - if (node.kind === 166 /* BindingElement */) { + if (node.kind === 167 /* BindingElement */) { name_32 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 214 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 215 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -40841,13 +42253,13 @@ var ts; else { return createItem(node, getTextOfNode(name_32), ts.ScriptElementKind.variableElement); } - case 145 /* Constructor */: + case 146 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 233 /* ExportSpecifier */: - case 229 /* ImportSpecifier */: - case 224 /* ImportEqualsDeclaration */: - case 226 /* ImportClause */: - case 227 /* NamespaceImport */: + case 234 /* ExportSpecifier */: + case 230 /* ImportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 227 /* ImportClause */: + case 228 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -40877,17 +42289,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 251 /* SourceFile */: + case 252 /* SourceFile */: return createSourceFileItem(node); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: return createClassItem(node); - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: return createEnumItem(node); - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return createModuleItem(node); - case 216 /* FunctionDeclaration */: + case 217 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -40899,7 +42311,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 221 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 222 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -40911,7 +42323,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 === 195 /* Block */) { + if (node.body && node.body.kind === 196 /* 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)); } @@ -40932,7 +42344,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 145 /* Constructor */ && member; + return member.kind === 146 /* 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 @@ -40956,7 +42368,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 137 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 138 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -40965,13 +42377,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 221 /* ModuleDeclaration */) { + while (node.body.kind === 222 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 251 /* SourceFile */ + return node.kind === 252 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -41722,7 +43134,7 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 171 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 172 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -41730,7 +43142,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 69 /* Identifier */ ? expression - : expression.kind === 169 /* PropertyAccessExpression */ + : expression.kind === 170 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -41742,8 +43154,8 @@ var ts; var nameToDeclarations = sourceFile_1.getNamedDeclarations(); var declarations = ts.getProperty(nameToDeclarations, name.text); if (declarations) { - for (var _b = 0, declarations_7 = declarations; _b < declarations_7.length; _b++) { - var declaration = declarations_7[_b]; + for (var _b = 0, declarations_8 = declarations; _b < declarations_8.length; _b++) { + var declaration = declarations_8[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -41763,7 +43175,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 171 /* CallExpression */ || node.parent.kind === 172 /* NewExpression */) { + if (node.parent.kind === 172 /* CallExpression */ || node.parent.kind === 173 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -41816,25 +43228,25 @@ var ts; }; } } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 173 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 174 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 173 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 174 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 186 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 187 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 193 /* TemplateSpan */ && node.parent.parent.parent.kind === 173 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 194 /* TemplateSpan */ && node.parent.parent.parent.kind === 174 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 186 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 187 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -41952,7 +43364,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 186 /* TemplateExpression */) { + if (template.kind === 187 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -41961,7 +43373,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 251 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 252 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -42161,40 +43573,40 @@ var ts; return false; } switch (n.kind) { - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 168 /* ObjectLiteralExpression */: - case 164 /* ObjectBindingPattern */: - case 156 /* TypeLiteral */: - case 195 /* Block */: - case 222 /* ModuleBlock */: - case 223 /* CaseBlock */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 169 /* ObjectLiteralExpression */: + case 165 /* ObjectBindingPattern */: + case 157 /* TypeLiteral */: + case 196 /* Block */: + case 223 /* ModuleBlock */: + case 224 /* CaseBlock */: return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 172 /* NewExpression */: + case 173 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 171 /* CallExpression */: - case 175 /* ParenthesizedExpression */: - case 161 /* ParenthesizedType */: + case 172 /* CallExpression */: + case 176 /* ParenthesizedExpression */: + case 162 /* ParenthesizedType */: return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 153 /* FunctionType */: - case 154 /* ConstructorType */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 149 /* ConstructSignature */: - case 148 /* CallSignature */: - case 177 /* ArrowFunction */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 150 /* ConstructSignature */: + case 149 /* CallSignature */: + case 178 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -42204,64 +43616,64 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 199 /* IfStatement */: + case 200 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 23 /* SemicolonToken */); - case 167 /* ArrayLiteralExpression */: - case 165 /* ArrayBindingPattern */: - case 170 /* ElementAccessExpression */: - case 137 /* ComputedPropertyName */: - case 158 /* TupleType */: + case 168 /* ArrayLiteralExpression */: + case 166 /* ArrayBindingPattern */: + case 171 /* ElementAccessExpression */: + case 138 /* ComputedPropertyName */: + case 159 /* TupleType */: return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 150 /* IndexSignature */: + case 151 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); - case 244 /* CaseClause */: - case 245 /* DefaultClause */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 201 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 202 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 200 /* DoStatement */: + case 201 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 155 /* TypeQuery */: + case 156 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 179 /* TypeOfExpression */: - case 178 /* DeleteExpression */: - case 180 /* VoidExpression */: - case 187 /* YieldExpression */: - case 188 /* SpreadElementExpression */: + case 180 /* TypeOfExpression */: + case 179 /* DeleteExpression */: + case 181 /* VoidExpression */: + case 188 /* YieldExpression */: + case 189 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 173 /* TaggedTemplateExpression */: + case 174 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 186 /* TemplateExpression */: + case 187 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 193 /* TemplateSpan */: + case 194 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 182 /* PrefixUnaryExpression */: + case 183 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 185 /* ConditionalExpression */: + case 186 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -42317,7 +43729,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 === 274 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 275 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -42423,7 +43835,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 239 /* JsxText */) { + if (isToken(n) || n.kind === 240 /* JsxText */) { return n; } var children = n.getChildren(); @@ -42431,7 +43843,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 239 /* JsxText */) { + if (isToken(n) || n.kind === 240 /* JsxText */) { return n; } var children = n.getChildren(); @@ -42445,10 +43857,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 239 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 240 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 239 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 240 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -42460,7 +43872,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 251 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 252 /* 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. @@ -42482,7 +43894,7 @@ var ts; ts.findPrecedingToken = findPrecedingToken; function isInString(sourceFile, position) { var token = getTokenAtPosition(sourceFile, position); - return token && (token.kind === 9 /* StringLiteral */ || token.kind === 163 /* StringLiteralType */) && position > token.getStart(); + return token && (token.kind === 9 /* StringLiteral */ || token.kind === 164 /* StringLiteralType */) && position > token.getStart(); } ts.isInString = isInString; function isInComment(sourceFile, position) { @@ -42568,17 +43980,17 @@ var ts; function getNodeModifiers(node) { var flags = ts.getCombinedNodeFlags(node); var result = []; - if (flags & 16 /* Private */) + if (flags & 8 /* Private */) result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 32 /* Protected */) + if (flags & 16 /* Protected */) result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 8 /* Public */) + if (flags & 4 /* Public */) result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 64 /* Static */) + if (flags & 32 /* Static */) result.push(ts.ScriptElementKindModifier.staticModifier); if (flags & 128 /* Abstract */) result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 2 /* Export */) + if (flags & 1 /* Export */) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) result.push(ts.ScriptElementKindModifier.ambientModifier); @@ -42586,17 +43998,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 152 /* TypeReference */ || node.kind === 171 /* CallExpression */) { + if (node.kind === 153 /* TypeReference */ || node.kind === 172 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 217 /* ClassDeclaration */ || node.kind === 218 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 218 /* ClassDeclaration */ || node.kind === 219 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 135 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 136 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -42612,7 +44024,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 163 /* StringLiteralType */ + || kind === 164 /* StringLiteralType */ || kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; @@ -42656,18 +44068,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 167 /* ArrayLiteralExpression */ || - node.kind === 168 /* ObjectLiteralExpression */) { + if (node.kind === 168 /* ArrayLiteralExpression */ || + node.kind === 169 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 184 /* BinaryExpression */ && + if (node.parent.kind === 185 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 56 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 204 /* ForOfStatement */ && + if (node.parent.kind === 205 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -42675,7 +44087,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 248 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 249 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -42688,7 +44100,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 139 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 140 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -42876,7 +44288,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 229 /* ImportSpecifier */ || location.parent.kind === 233 /* ExportSpecifier */) && + (location.parent.kind === 230 /* ImportSpecifier */ || location.parent.kind === 234 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -42999,10 +44411,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 241 /* JsxAttribute */: - case 238 /* JsxOpeningElement */: - case 240 /* JsxClosingElement */: - case 237 /* JsxSelfClosingElement */: + case 242 /* JsxAttribute */: + case 239 /* JsxOpeningElement */: + case 241 /* JsxClosingElement */: + case 238 /* JsxSelfClosingElement */: return node.kind === 69 /* Identifier */; } } @@ -43391,25 +44803,25 @@ 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, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* 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, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* 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(53 /* 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(53 /* 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 */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Space after }. - 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 */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* 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 */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext), 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 */)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); @@ -43422,7 +44834,7 @@ var ts; // 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(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 */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. 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] @@ -43430,79 +44842,79 @@ var ts; // 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(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* 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, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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(41 /* 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 */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* 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 */, 42 /* 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([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), 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([108 /* LetKeyword */, 74 /* 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.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* 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(103 /* 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(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* 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 */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 129 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 130 /* SetKeyword */]), 69 /* 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 */)); + this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // 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(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 127 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* ModuleKeyword */, 128 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 129 /* SetKeyword */, 113 /* StaticKeyword */, 132 /* TypeKeyword */]), 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([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 130 /* SetKeyword */, 113 /* StaticKeyword */, 133 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34 /* EqualsGreaterThanToken */), 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 */)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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 */)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* 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.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* 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([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 129 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 130 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* 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([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* 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([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // template string - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -43563,13 +44975,13 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), 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 */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */)); + this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements 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 */)); @@ -43581,25 +44993,25 @@ var ts; // Open Brace braces after control block 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(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 */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - 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 */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing template string braces - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Insert space after function keyword for anonymous functions this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); @@ -43617,40 +45029,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 202 /* ForStatement */; + return context.contextNode.kind === 203 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 184 /* BinaryExpression */: - case 185 /* ConditionalExpression */: - case 192 /* AsExpression */: - case 151 /* TypePredicate */: - case 159 /* UnionType */: - case 160 /* IntersectionType */: + case 185 /* BinaryExpression */: + case 186 /* ConditionalExpression */: + case 193 /* AsExpression */: + case 152 /* TypePredicate */: + case 160 /* UnionType */: + case 161 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 166 /* BindingElement */: + case 167 /* BindingElement */: // equals in type X = ... - case 219 /* TypeAliasDeclaration */: + case 220 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 214 /* VariableDeclaration */: + case 215 /* VariableDeclaration */: // equal in p = 0; - case 139 /* Parameter */: - case 250 /* EnumMember */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 140 /* Parameter */: + case 251 /* EnumMember */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 203 /* ForInStatement */: + case 204 /* ForInStatement */: return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 204 /* ForOfStatement */: - return context.currentTokenSpan.kind === 135 /* OfKeyword */ || context.nextTokenSpan.kind === 135 /* OfKeyword */; + case 205 /* ForOfStatement */: + return context.currentTokenSpan.kind === 136 /* OfKeyword */ || context.nextTokenSpan.kind === 136 /* OfKeyword */; } return false; }; @@ -43658,7 +45070,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 185 /* ConditionalExpression */; + return context.contextNode.kind === 186 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -43702,93 +45114,93 @@ var ts; return true; } switch (node.kind) { - case 195 /* Block */: - case 223 /* CaseBlock */: - case 168 /* ObjectLiteralExpression */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 224 /* CaseBlock */: + case 169 /* ObjectLiteralExpression */: + case 223 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 148 /* CallSignature */: - case 176 /* FunctionExpression */: - case 145 /* Constructor */: - case 177 /* ArrowFunction */: + case 149 /* CallSignature */: + case 177 /* FunctionExpression */: + case 146 /* Constructor */: + case 178 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 216 /* FunctionDeclaration */ || context.contextNode.kind === 176 /* FunctionExpression */; + return context.contextNode.kind === 217 /* FunctionDeclaration */ || context.contextNode.kind === 177 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 156 /* TypeLiteral */: - case 221 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 157 /* TypeLiteral */: + case 222 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 217 /* ClassDeclaration */: - case 221 /* ModuleDeclaration */: - case 220 /* EnumDeclaration */: - case 195 /* Block */: - case 247 /* CatchClause */: - case 222 /* ModuleBlock */: - case 209 /* SwitchStatement */: + case 218 /* ClassDeclaration */: + case 222 /* ModuleDeclaration */: + case 221 /* EnumDeclaration */: + case 196 /* Block */: + case 248 /* CatchClause */: + case 223 /* ModuleBlock */: + case 210 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 199 /* IfStatement */: - case 209 /* SwitchStatement */: - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 201 /* WhileStatement */: - case 212 /* TryStatement */: - case 200 /* DoStatement */: - case 208 /* WithStatement */: + case 200 /* IfStatement */: + case 210 /* SwitchStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 202 /* WhileStatement */: + case 213 /* TryStatement */: + case 201 /* DoStatement */: + case 209 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 247 /* CatchClause */: + case 248 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 168 /* ObjectLiteralExpression */; + return context.contextNode.kind === 169 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 171 /* CallExpression */; + return context.contextNode.kind === 172 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 172 /* NewExpression */; + return context.contextNode.kind === 173 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -43800,10 +45212,10 @@ var ts; return context.nextTokenSpan.kind !== 20 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 177 /* ArrowFunction */; + return context.contextNode.kind === 178 /* ArrowFunction */; }; - Rules.IsSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine(); + Rules.IsNonJsxSameLineTokenContext = function (context) { + return context.TokensAreOnSameLine() && context.contextNode.kind !== 240 /* JsxText */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -43818,41 +45230,41 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 140 /* Decorator */; + return node.kind === 141 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 215 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 216 /* 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 === 221 /* ModuleDeclaration */; + return context.contextNode.kind === 222 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 156 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 157 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 152 /* TypeReference */: - case 174 /* TypeAssertionExpression */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 191 /* ExpressionWithTypeArguments */: + case 153 /* TypeReference */: + case 175 /* TypeAssertionExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 192 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -43863,13 +45275,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 174 /* TypeAssertionExpression */; + return context.contextNode.kind === 175 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 180 /* VoidExpression */; + return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 181 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 187 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 188 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -43893,7 +45305,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 135 /* LastToken */ + 1; + this.mapRowLength = 136 /* 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); @@ -44088,7 +45500,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 135 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 136 /* LastToken */; token++) { result.push(token); } return result; @@ -44130,9 +45542,9 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 135 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 136 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 135 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 136 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); @@ -44140,7 +45552,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 128 /* NumberKeyword */, 130 /* StringKeyword */, 120 /* BooleanKeyword */, 131 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 129 /* NumberKeyword */, 131 /* StringKeyword */, 120 /* BooleanKeyword */, 132 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); return TokenRange; }()); Shared.TokenRange = TokenRange; @@ -44362,17 +45774,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 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 195 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 251 /* SourceFile */: - case 195 /* Block */: - case 222 /* ModuleBlock */: + return body && body.kind === 196 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 252 /* SourceFile */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -44574,19 +45986,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 217 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 218 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 216 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 220 /* EnumDeclaration */: return 220 /* EnumDeclaration */; - case 146 /* GetAccessor */: return 123 /* GetKeyword */; - case 147 /* SetAccessor */: return 129 /* SetKeyword */; - case 144 /* MethodDeclaration */: + case 218 /* ClassDeclaration */: return 73 /* ClassKeyword */; + case 219 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; + case 217 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; + case 221 /* EnumDeclaration */: return 221 /* EnumDeclaration */; + case 147 /* GetAccessor */: return 123 /* GetKeyword */; + case 148 /* SetAccessor */: return 130 /* SetKeyword */; + case 145 /* MethodDeclaration */: if (node.asteriskToken) { return 37 /* AsteriskToken */; } // fall-through - case 142 /* PropertyDeclaration */: - case 139 /* Parameter */: + case 143 /* PropertyDeclaration */: + case 140 /* Parameter */: return node.name.kind; } } @@ -44726,7 +46138,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 140 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 141 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -45070,20 +46482,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 195 /* Block */: - case 222 /* ModuleBlock */: + case 196 /* Block */: + case 223 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 145 /* Constructor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 177 /* ArrowFunction */: + case 146 /* Constructor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 178 /* ArrowFunction */: if (node.typeParameters === list) { return 25 /* LessThanToken */; } @@ -45091,8 +46503,8 @@ var ts; return 17 /* OpenParenToken */; } break; - case 171 /* CallExpression */: - case 172 /* NewExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -45100,7 +46512,7 @@ var ts; return 17 /* OpenParenToken */; } break; - case 152 /* TypeReference */: + case 153 /* TypeReference */: if (node.typeArguments === list) { return 25 /* LessThanToken */; } @@ -45129,7 +46541,7 @@ var ts; if (!options.ConvertTabsToSpaces) { var tabs = Math.floor(indentation / options.TabSize); var spaces = indentation - tabs * options.TabSize; - var tabString; + var tabString = void 0; if (!internedTabsIndentation) { internedTabsIndentation = []; } @@ -45142,7 +46554,7 @@ var ts; return spaces ? tabString + repeat(" ", spaces) : tabString; } else { - var spacesString; + var spacesString = void 0; var quotient = Math.floor(indentation / options.IndentSize); var remainder = indentation % options.IndentSize; if (!internedSpacesIndentation) { @@ -45216,7 +46628,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 184 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 185 /* 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 */) { @@ -45335,7 +46747,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 === 251 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 252 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -45368,7 +46780,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 199 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 200 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -45380,23 +46792,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 152 /* TypeReference */: + case 153 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 168 /* ObjectLiteralExpression */: + case 169 /* ObjectLiteralExpression */: return node.parent.properties; - case 167 /* ArrayLiteralExpression */: + case 168 /* ArrayLiteralExpression */: return node.parent.elements; - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: { + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -45407,8 +46819,8 @@ var ts; } break; } - case 172 /* NewExpression */: - case 171 /* CallExpression */: { + case 173 /* NewExpression */: + case 172 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -45438,8 +46850,8 @@ var ts; if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 171 /* CallExpression */ || - node.parent.kind === 172 /* NewExpression */) && + if (node.parent && (node.parent.kind === 172 /* CallExpression */ || + node.parent.kind === 173 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -45457,10 +46869,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 169 /* PropertyAccessExpression */: - case 170 /* ElementAccessExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 170 /* PropertyAccessExpression */: + case 171 /* ElementAccessExpression */: node = node.expression; break; default: @@ -45524,45 +46936,45 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 198 /* ExpressionStatement */: - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 167 /* ArrayLiteralExpression */: - case 195 /* Block */: - case 222 /* ModuleBlock */: - case 168 /* ObjectLiteralExpression */: - case 156 /* TypeLiteral */: - case 158 /* TupleType */: - case 223 /* CaseBlock */: - case 245 /* DefaultClause */: - case 244 /* CaseClause */: - case 175 /* ParenthesizedExpression */: - case 169 /* PropertyAccessExpression */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 196 /* VariableStatement */: - case 214 /* VariableDeclaration */: - case 230 /* ExportAssignment */: - case 207 /* ReturnStatement */: - case 185 /* ConditionalExpression */: - case 165 /* ArrayBindingPattern */: - case 164 /* ObjectBindingPattern */: - case 238 /* JsxOpeningElement */: - case 237 /* JsxSelfClosingElement */: - case 243 /* JsxExpression */: - case 143 /* MethodSignature */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 139 /* Parameter */: - case 153 /* FunctionType */: - case 154 /* ConstructorType */: - case 161 /* ParenthesizedType */: - case 173 /* TaggedTemplateExpression */: - case 181 /* AwaitExpression */: - case 228 /* NamedImports */: + case 199 /* ExpressionStatement */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 168 /* ArrayLiteralExpression */: + case 196 /* Block */: + case 223 /* ModuleBlock */: + case 169 /* ObjectLiteralExpression */: + case 157 /* TypeLiteral */: + case 159 /* TupleType */: + case 224 /* CaseBlock */: + case 246 /* DefaultClause */: + case 245 /* CaseClause */: + case 176 /* ParenthesizedExpression */: + case 170 /* PropertyAccessExpression */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 197 /* VariableStatement */: + case 215 /* VariableDeclaration */: + case 231 /* ExportAssignment */: + case 208 /* ReturnStatement */: + case 186 /* ConditionalExpression */: + case 166 /* ArrayBindingPattern */: + case 165 /* ObjectBindingPattern */: + case 239 /* JsxOpeningElement */: + case 238 /* JsxSelfClosingElement */: + case 244 /* JsxExpression */: + case 144 /* MethodSignature */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 140 /* Parameter */: + case 154 /* FunctionType */: + case 155 /* ConstructorType */: + case 162 /* ParenthesizedType */: + case 174 /* TaggedTemplateExpression */: + case 182 /* AwaitExpression */: + case 229 /* NamedImports */: return true; } return false; @@ -45571,22 +46983,22 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 200 /* DoStatement */: - case 201 /* WhileStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 202 /* ForStatement */: - case 199 /* IfStatement */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 144 /* MethodDeclaration */: - case 177 /* ArrowFunction */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - return childKind !== 195 /* Block */; - case 236 /* JsxElement */: - return childKind !== 240 /* JsxClosingElement */; + case 201 /* DoStatement */: + case 202 /* WhileStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 203 /* ForStatement */: + case 200 /* IfStatement */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 145 /* MethodDeclaration */: + case 178 /* ArrowFunction */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + return childKind !== 196 /* Block */; + case 237 /* JsxElement */: + return childKind !== 241 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -45603,11 +47015,6 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// -var __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 __()); -}; /// /// /// @@ -45732,13 +47139,13 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 2048 /* Synthetic */, this)); + nodes.push(createNode(token, pos, textPos, 0, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(274 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); + var list = createNode(275 /* SyntaxList */, nodes.pos, nodes.end, 0, this); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -45757,27 +47164,27 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 136 /* FirstNode */) { + if (this.kind >= 137 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; - var pos = this.pos; + var pos_3 = this.pos; var processNode = function (node) { - if (pos < node.pos) { - pos = _this.addSyntheticNodes(children, pos, node.pos); + if (pos_3 < node.pos) { + pos_3 = _this.addSyntheticNodes(children, pos_3, node.pos); } children.push(node); - pos = node.end; + pos_3 = node.end; }; var processNodes = function (nodes) { - if (pos < nodes.pos) { - pos = _this.addSyntheticNodes(children, pos, nodes.pos); + if (pos_3 < nodes.pos) { + pos_3 = _this.addSyntheticNodes(children, pos_3, nodes.pos); } children.push(_this.createSyntaxList(nodes)); - pos = nodes.end; + pos_3 = nodes.end; }; ts.forEachChild(this, processNode, processNodes); - if (pos < this.end) { - this.addSyntheticNodes(children, pos, this.end); + if (pos_3 < this.end) { + this.addSyntheticNodes(children, pos_3, this.end); } scanner.setText(undefined); } @@ -45804,7 +47211,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 136 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 137 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -45812,7 +47219,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 136 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 137 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -45859,27 +47266,27 @@ var ts; // 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); + var sourceFileOfDeclaration_1 = 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 === 139 /* Parameter */) { - ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (canUseParsedParamTagComments && declaration.kind === 140 /* Parameter */) { + ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration_1), function (jsDocCommentTextRange) { + var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration_1); if (cleanedParamJsDocComment) { ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); } }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 221 /* ModuleDeclaration */ && declaration.body.kind === 221 /* ModuleDeclaration */) { + if (declaration.kind === 222 /* ModuleDeclaration */ && declaration.body.kind === 222 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 221 /* ModuleDeclaration */ && declaration.parent.kind === 221 /* ModuleDeclaration */) { + while (declaration.kind === 222 /* ModuleDeclaration */ && declaration.parent.kind === 222 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 214 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { - var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + ts.forEach(getJsDocCommentTextRange(declaration.kind === 215 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration_1), function (jsDocCommentTextRange) { + var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration_1); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); } @@ -45953,7 +47360,7 @@ var ts; else if (spacesToRemoveAfterAsterisk === undefined) { spacesToRemoveAfterAsterisk = 0; } - // Analyse text on this line + // Analyze text on this line while (pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { var ch = sourceFile.text.charAt(pos); if (ch === "@") { @@ -46073,7 +47480,7 @@ var ts; } paramHelpStringMargin = undefined; } - // If this is the start of another tag, continue with the loop in seach of param tag with symbol name + // If this is the start of another tag, continue with the loop in search of param tag with symbol name if (sourceFile.text.charCodeAt(pos) === 64 /* at */) { continue; } @@ -46223,9 +47630,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 137 /* ComputedPropertyName */) { + if (declaration.name.kind === 138 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 169 /* PropertyAccessExpression */) { + if (expr.kind === 170 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -46245,9 +47652,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -46267,60 +47674,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 220 /* EnumDeclaration */: - case 221 /* ModuleDeclaration */: - case 224 /* ImportEqualsDeclaration */: - case 233 /* ExportSpecifier */: - case 229 /* ImportSpecifier */: - case 224 /* ImportEqualsDeclaration */: - case 226 /* ImportClause */: - case 227 /* NamespaceImport */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 156 /* TypeLiteral */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 221 /* EnumDeclaration */: + case 222 /* ModuleDeclaration */: + case 225 /* ImportEqualsDeclaration */: + case 234 /* ExportSpecifier */: + case 230 /* ImportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 227 /* ImportClause */: + case 228 /* NamespaceImport */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 157 /* TypeLiteral */: addDeclaration(node); // fall through - case 145 /* Constructor */: - case 196 /* VariableStatement */: - case 215 /* VariableDeclarationList */: - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: - case 222 /* ModuleBlock */: + case 146 /* Constructor */: + case 197 /* VariableStatement */: + case 216 /* VariableDeclarationList */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: + case 223 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 195 /* Block */: + case 196 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 139 /* Parameter */: + case 140 /* Parameter */: // Only consider properties defined as constructor parameters - if (!(node.flags & 56 /* AccessibilityModifier */)) { + if (!(node.flags & 28 /* AccessibilityModifier */)) { break; } // fall through - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 250 /* EnumMember */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 251 /* EnumMember */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: addDeclaration(node); break; - case 231 /* ExportDeclaration */: + case 232 /* 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 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -46332,7 +47739,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 227 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 228 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -46554,16 +47961,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 176 /* FunctionExpression */) { + if (declaration.kind === 177 /* FunctionExpression */) { return true; } - if (declaration.kind !== 214 /* VariableDeclaration */ && declaration.kind !== 216 /* FunctionDeclaration */) { + if (declaration.kind !== 215 /* VariableDeclaration */ && declaration.kind !== 217 /* 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_10 = declaration.parent; !ts.isFunctionBlock(parent_10); parent_10 = parent_10.parent) { // Reached source file or module block - if (parent_9.kind === 251 /* SourceFile */ || parent_9.kind === 222 /* ModuleBlock */) { + if (parent_10.kind === 252 /* SourceFile */ || parent_10.kind === 223 /* ModuleBlock */) { return false; } } @@ -46575,7 +47982,6 @@ var ts; // Always default to "ScriptTarget.ES5" for the language service return { target: 1 /* ES5 */, - module: 0 /* None */, jsx: 1 /* Preserve */ }; } @@ -46604,12 +48010,14 @@ var ts; }; HostCache.prototype.createEntry = function (fileName, path) { var entry; + var scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : 0 /* Unknown */; var scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { entry = { hostFileName: fileName, version: this.host.getScriptVersion(fileName), - scriptSnapshot: scriptSnapshot + scriptSnapshot: scriptSnapshot, + scriptKind: scriptKind ? scriptKind : ts.getScriptKindFromFileName(fileName) }; } this.fileNameToEntry.set(path, entry); @@ -46657,11 +48065,12 @@ var ts; // The host does not know about this file. throw new Error("Could not find file: '" + fileName + "'."); } + var scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : 0 /* Unknown */; var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents*/ true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents*/ true, scriptKind); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -46695,6 +48104,8 @@ var ts; function transpileModule(input, transpileOptions) { var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; + // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. + options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; // We are not returning a sourceFile for lib file when asked by the program, @@ -46759,12 +48170,10 @@ var ts; return output.outputText; } ts.transpile = transpile; - function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { + function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) { var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); - var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents); + var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents, scriptKind); setSourceFileFields(sourceFile, scriptSnapshot, version); - // after full parsing we can use table with interned strings as name table - sourceFile.nameTable = sourceFile.identifiers; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; @@ -46776,7 +48185,7 @@ var ts; if (version !== sourceFile.version) { // Once incremental parsing is ready, then just call into this function. if (!ts.disableIncrementalParsing) { - var newText; + var newText = void 0; // grab the fragment from the beginning of the original text to the beginning of the span var prefix = textChangeRange.span.start !== 0 ? sourceFile.text.substr(0, textChangeRange.span.start) @@ -46816,7 +48225,7 @@ var ts; } } // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true); + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { @@ -46855,20 +48264,20 @@ var ts; }); return JSON.stringify(bucketInfoArray, undefined, 2); } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ true); + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ true, scriptKind); } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ false); + function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } - function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { + function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring, scriptKind) { var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var entry = bucket.get(path); 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, /*setNodeParents*/ false); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false, scriptKind); entry = { sourceFile: sourceFile, languageServiceRefCount: 0, @@ -46982,7 +48391,7 @@ var ts; else { if (token === 69 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -47013,7 +48422,7 @@ var ts; } if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -47029,7 +48438,7 @@ var ts; token = scanner.scan(); if (token === 69 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -47058,7 +48467,7 @@ var ts; } if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -47070,7 +48479,7 @@ var ts; } else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 133 /* FromKeyword */) { + if (token === 134 /* FromKeyword */) { token = scanner.scan(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -47095,7 +48504,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? scanner.scan() : scanner.getToken(); - if (token === 127 /* RequireKeyword */) { + if (token === 128 /* RequireKeyword */) { token = scanner.scan(); if (token === 17 /* OpenParenToken */) { token = scanner.scan(); @@ -47189,7 +48598,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 210 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 211 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -47198,12 +48607,12 @@ var ts; } function isJumpStatementTarget(node) { return node.kind === 69 /* Identifier */ && - (node.parent.kind === 206 /* BreakStatement */ || node.parent.kind === 205 /* ContinueStatement */) && + (node.parent.kind === 207 /* BreakStatement */ || node.parent.kind === 206 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { return node.kind === 69 /* Identifier */ && - node.parent.kind === 210 /* LabeledStatement */ && + node.parent.kind === 211 /* LabeledStatement */ && node.parent.label === node; } /** @@ -47211,7 +48620,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 210 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 211 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -47222,25 +48631,25 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 136 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 137 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 169 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 170 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 171 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 172 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 172 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 173 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 221 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 222 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { return node.kind === 69 /* Identifier */ && @@ -47249,22 +48658,22 @@ var ts; /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { return (node.kind === 69 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - (node.parent.kind === 248 /* PropertyAssignment */ || node.parent.kind === 249 /* ShorthandPropertyAssignment */) && node.parent.name === node; + (node.parent.kind === 249 /* PropertyAssignment */ || node.parent.kind === 250 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 248 /* PropertyAssignment */: - case 250 /* EnumMember */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 221 /* ModuleDeclaration */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 249 /* PropertyAssignment */: + case 251 /* EnumMember */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 222 /* ModuleDeclaration */: return node.parent.name === node; - case 170 /* ElementAccessExpression */: + case 171 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -47323,7 +48732,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 135 /* LastKeyword */; i++) { + for (var i = 70 /* FirstKeyword */; i <= 136 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -47338,17 +48747,17 @@ var ts; return undefined; } switch (node.kind) { - case 251 /* SourceFile */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 220 /* EnumDeclaration */: - case 221 /* ModuleDeclaration */: + case 252 /* SourceFile */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 221 /* EnumDeclaration */: + case 222 /* ModuleDeclaration */: return node; } } @@ -47356,38 +48765,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 221 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 217 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 218 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 219 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 220 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 214 /* VariableDeclaration */: + case 222 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 218 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 219 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 220 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 221 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 215 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 216 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 146 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 147 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 217 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 147 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 148 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 150 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 149 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 148 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 145 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 138 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 250 /* EnumMember */: return ScriptElementKind.variableElement; - case 139 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 224 /* ImportEqualsDeclaration */: - case 229 /* ImportSpecifier */: - case 226 /* ImportClause */: - case 233 /* ExportSpecifier */: - case 227 /* NamespaceImport */: + case 151 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 150 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 149 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 146 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 139 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 251 /* EnumMember */: return ScriptElementKind.variableElement; + case 140 /* Parameter */: return (node.flags & 28 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 225 /* ImportEqualsDeclaration */: + case 230 /* ImportSpecifier */: + case 227 /* ImportClause */: + case 234 /* ExportSpecifier */: + case 228 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -47496,6 +48905,9 @@ var ts; return ts.directoryProbablyExists(directoryName, host); } }; + if (host.trace) { + compilerHost.trace = function (message) { return host.trace(message); }; + } if (host.resolveModuleNames) { compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; } @@ -47529,7 +48941,7 @@ var ts; return undefined; } // Check if the language version has changed since we last created a program; if they are the same, - // it is safe to reuse the souceFiles; if not, then the shape of the AST can change, and the oldSourceFile + // it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile // can not be reused. we have to dump all syntax trees and create new ones. if (!changesInCompilationSettingsAffectSyntax) { // Check if the old program had this file already @@ -47537,7 +48949,7 @@ var ts; if (oldSourceFile) { // 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: + // address the following race-condition. Specifically, say we have the following: // // LS1 // \ @@ -47556,11 +48968,15 @@ var ts; // 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 // host says should be used. - return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + // We do not support the scenario where a host can modify a registered + // file's script kind, i.e. in one project some file is treated as ".ts" + // and in another as ".js" + ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + fileName); + return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } } // Could not find this file in the old program, create a new SourceFile for it. - return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); + return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } function sourceFileUpToDate(sourceFile) { if (!sourceFile) { @@ -47610,7 +49026,7 @@ var ts; return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); } /** - * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors + * getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors * If '-d' enabled, report both semantic and emitter errors */ function getSemanticDiagnostics(fileName) { @@ -47699,9 +49115,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 272 /* JSDocTypeTag */: - case 270 /* JSDocParameterTag */: - case 271 /* JSDocReturnTag */: + case 273 /* JSDocTypeTag */: + case 271 /* JSDocParameterTag */: + case 272 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -47746,13 +49162,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; + var parent_11 = contextToken.parent, kind = contextToken.kind; if (kind === 21 /* DotToken */) { - if (parent_10.kind === 169 /* PropertyAccessExpression */) { + if (parent_11.kind === 170 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 136 /* QualifiedName */) { + else if (parent_11.kind === 137 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -47767,7 +49183,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 240 /* JsxClosingElement */) { + else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 241 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -47814,7 +49230,7 @@ var ts; // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 136 /* QualifiedName */ || node.kind === 169 /* PropertyAccessExpression */) { + if (node.kind === 69 /* Identifier */ || node.kind === 137 /* QualifiedName */ || node.kind === 170 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -47869,8 +49285,8 @@ var ts; return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { - var attrsType; - if ((jsxContainer.kind === 237 /* JsxSelfClosingElement */) || (jsxContainer.kind === 238 /* JsxOpeningElement */)) { + var attrsType = void 0; + if ((jsxContainer.kind === 238 /* JsxSelfClosingElement */) || (jsxContainer.kind === 239 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -47942,15 +49358,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 239 /* JsxText */) { + if (contextToken.kind === 240 /* JsxText */) { return true; } if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 238 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 239 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 240 /* JsxClosingElement */ || contextToken.parent.kind === 237 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 236 /* JsxElement */; + if (contextToken.parent.kind === 241 /* JsxClosingElement */ || contextToken.parent.kind === 238 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 237 /* JsxElement */; } } return false; @@ -47960,40 +49376,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 171 /* CallExpression */ // func( a, | - || containingNodeKind === 145 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 172 /* NewExpression */ // new C(a, | - || containingNodeKind === 167 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 184 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 153 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 172 /* CallExpression */ // func( a, | + || containingNodeKind === 146 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 173 /* NewExpression */ // new C(a, | + || containingNodeKind === 168 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 185 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 154 /* FunctionType */; // var x: (s: string, list| case 17 /* OpenParenToken */: - return containingNodeKind === 171 /* CallExpression */ // func( | - || containingNodeKind === 145 /* Constructor */ // constructor( | - || containingNodeKind === 172 /* NewExpression */ // new C(a| - || containingNodeKind === 175 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 161 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 172 /* CallExpression */ // func( | + || containingNodeKind === 146 /* Constructor */ // constructor( | + || containingNodeKind === 173 /* NewExpression */ // new C(a| + || containingNodeKind === 176 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 162 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 19 /* OpenBracketToken */: - return containingNodeKind === 167 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 150 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 137 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 168 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 151 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 138 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 125 /* ModuleKeyword */: // module | case 126 /* NamespaceKeyword */: return true; case 21 /* DotToken */: - return containingNodeKind === 221 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 222 /* ModuleDeclaration */; // module A.| case 15 /* OpenBraceToken */: - return containingNodeKind === 217 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 218 /* ClassDeclaration */; // class A{ | case 56 /* EqualsToken */: - return containingNodeKind === 214 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 184 /* BinaryExpression */; // x = a| + return containingNodeKind === 215 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 185 /* BinaryExpression */; // x = a| case 12 /* TemplateHead */: - return containingNodeKind === 186 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 187 /* TemplateExpression */; // `aa ${| case 13 /* TemplateMiddle */: - return containingNodeKind === 193 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 194 /* TemplateSpan */; // `aa ${10} dd ${| case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: - return containingNodeKind === 142 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 143 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -48007,7 +49423,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 163 /* StringLiteralType */ + || contextToken.kind === 164 /* StringLiteralType */ || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_7 = contextToken.getStart(); @@ -48037,14 +49453,14 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 168 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 169 /* 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 === 164 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 165 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -48090,9 +49506,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 228 /* NamedImports */ ? - 225 /* ImportDeclaration */ : - 231 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 229 /* NamedImports */ ? + 226 /* ImportDeclaration */ : + 232 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -48117,9 +49533,9 @@ var ts; switch (contextToken.kind) { case 15 /* OpenBraceToken */: // const x = { | case 24 /* CommaToken */: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 168 /* ObjectLiteralExpression */ || parent_11.kind === 164 /* ObjectBindingPattern */)) { - return parent_11; + var parent_12 = contextToken.parent; + if (parent_12 && (parent_12.kind === 169 /* ObjectLiteralExpression */ || parent_12.kind === 165 /* ObjectBindingPattern */)) { + return parent_12; } break; } @@ -48136,8 +49552,8 @@ var ts; case 15 /* OpenBraceToken */: // import { | case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 228 /* NamedImports */: - case 232 /* NamedExports */: + case 229 /* NamedImports */: + case 233 /* NamedExports */: return contextToken.parent; } } @@ -48146,37 +49562,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_13 = contextToken.parent; switch (contextToken.kind) { case 26 /* LessThanSlashToken */: case 39 /* SlashToken */: case 69 /* Identifier */: - case 241 /* JsxAttribute */: - case 242 /* JsxSpreadAttribute */: - if (parent_12 && (parent_12.kind === 237 /* JsxSelfClosingElement */ || parent_12.kind === 238 /* JsxOpeningElement */)) { - return parent_12; + case 242 /* JsxAttribute */: + case 243 /* JsxSpreadAttribute */: + if (parent_13 && (parent_13.kind === 238 /* JsxSelfClosingElement */ || parent_13.kind === 239 /* JsxOpeningElement */)) { + return parent_13; } - else if (parent_12.kind === 241 /* JsxAttribute */) { - return parent_12.parent; + else if (parent_13.kind === 242 /* JsxAttribute */) { + return parent_13.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_12 && ((parent_12.kind === 241 /* JsxAttribute */) || (parent_12.kind === 242 /* JsxSpreadAttribute */))) { - return parent_12.parent; + if (parent_13 && ((parent_13.kind === 242 /* JsxAttribute */) || (parent_13.kind === 243 /* JsxSpreadAttribute */))) { + return parent_13.parent; } break; case 16 /* CloseBraceToken */: - if (parent_12 && - parent_12.kind === 243 /* JsxExpression */ && - parent_12.parent && - (parent_12.parent.kind === 241 /* JsxAttribute */)) { - return parent_12.parent.parent; + if (parent_13 && + parent_13.kind === 244 /* JsxExpression */ && + parent_13.parent && + (parent_13.parent.kind === 242 /* JsxAttribute */)) { + return parent_13.parent.parent; } - if (parent_12 && parent_12.kind === 242 /* JsxSpreadAttribute */) { - return parent_12.parent; + if (parent_13 && parent_13.kind === 243 /* JsxSpreadAttribute */) { + return parent_13.parent; } break; } @@ -48185,16 +49601,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 148 /* CallSignature */: - case 149 /* ConstructSignature */: - case 150 /* IndexSignature */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 149 /* CallSignature */: + case 150 /* ConstructSignature */: + case 151 /* IndexSignature */: return true; } return false; @@ -48206,66 +49622,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 24 /* CommaToken */: - return containingNodeKind === 214 /* VariableDeclaration */ || - containingNodeKind === 215 /* VariableDeclarationList */ || - containingNodeKind === 196 /* VariableStatement */ || - containingNodeKind === 220 /* EnumDeclaration */ || + return containingNodeKind === 215 /* VariableDeclaration */ || + containingNodeKind === 216 /* VariableDeclarationList */ || + containingNodeKind === 197 /* VariableStatement */ || + containingNodeKind === 221 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 217 /* ClassDeclaration */ || - containingNodeKind === 189 /* ClassExpression */ || - containingNodeKind === 218 /* InterfaceDeclaration */ || - containingNodeKind === 165 /* ArrayBindingPattern */ || - containingNodeKind === 219 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 218 /* ClassDeclaration */ || + containingNodeKind === 190 /* ClassExpression */ || + containingNodeKind === 219 /* InterfaceDeclaration */ || + containingNodeKind === 166 /* ArrayBindingPattern */ || + containingNodeKind === 220 /* TypeAliasDeclaration */; // type Map, K, | case 21 /* DotToken */: - return containingNodeKind === 165 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 166 /* ArrayBindingPattern */; // var [.| case 54 /* ColonToken */: - return containingNodeKind === 166 /* BindingElement */; // var {x :html| + return containingNodeKind === 167 /* BindingElement */; // var {x :html| case 19 /* OpenBracketToken */: - return containingNodeKind === 165 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 166 /* ArrayBindingPattern */; // var [x| case 17 /* OpenParenToken */: - return containingNodeKind === 247 /* CatchClause */ || + return containingNodeKind === 248 /* CatchClause */ || isFunction(containingNodeKind); case 15 /* OpenBraceToken */: - return containingNodeKind === 220 /* EnumDeclaration */ || - containingNodeKind === 218 /* InterfaceDeclaration */ || - containingNodeKind === 156 /* TypeLiteral */; // const x : { | + return containingNodeKind === 221 /* EnumDeclaration */ || + containingNodeKind === 219 /* InterfaceDeclaration */ || + containingNodeKind === 157 /* TypeLiteral */; // const x : { | case 23 /* SemicolonToken */: - return containingNodeKind === 141 /* PropertySignature */ && + return containingNodeKind === 142 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 218 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 156 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 219 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 157 /* TypeLiteral */); // const x : { a; | case 25 /* LessThanToken */: - return containingNodeKind === 217 /* ClassDeclaration */ || - containingNodeKind === 189 /* ClassExpression */ || - containingNodeKind === 218 /* InterfaceDeclaration */ || - containingNodeKind === 219 /* TypeAliasDeclaration */ || + return containingNodeKind === 218 /* ClassDeclaration */ || + containingNodeKind === 190 /* ClassExpression */ || + containingNodeKind === 219 /* InterfaceDeclaration */ || + containingNodeKind === 220 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 113 /* StaticKeyword */: - return containingNodeKind === 142 /* PropertyDeclaration */; + return containingNodeKind === 143 /* PropertyDeclaration */; case 22 /* DotDotDotToken */: - return containingNodeKind === 139 /* Parameter */ || + return containingNodeKind === 140 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 165 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 166 /* ArrayBindingPattern */); // var [...z| case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: case 111 /* ProtectedKeyword */: - return containingNodeKind === 139 /* Parameter */; + return containingNodeKind === 140 /* Parameter */; case 116 /* AsKeyword */: - return containingNodeKind === 229 /* ImportSpecifier */ || - containingNodeKind === 233 /* ExportSpecifier */ || - containingNodeKind === 227 /* NamespaceImport */; + return containingNodeKind === 230 /* ImportSpecifier */ || + containingNodeKind === 234 /* ExportSpecifier */ || + containingNodeKind === 228 /* NamespaceImport */; case 73 /* ClassKeyword */: case 81 /* EnumKeyword */: case 107 /* InterfaceKeyword */: case 87 /* FunctionKeyword */: case 102 /* VarKeyword */: case 123 /* GetKeyword */: - case 129 /* SetKeyword */: + case 130 /* SetKeyword */: case 89 /* ImportKeyword */: case 108 /* LetKeyword */: case 74 /* ConstKeyword */: case 114 /* YieldKeyword */: - case 132 /* TypeKeyword */: + case 133 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -48306,7 +49722,7 @@ var ts; * do not occur at the current position and have not otherwise been typed. */ function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { - var exisingImportsOrExports = {}; + var existingImportsOrExports = {}; for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { var element = namedImportsOrExports_1[_i]; // If this is the current item we are editing right now, do not filter it out @@ -48314,12 +49730,12 @@ var ts; continue; } var name_34 = element.propertyName || element.name; - exisingImportsOrExports[name_34.text] = true; + existingImportsOrExports[name_34.text] = true; } - if (ts.isEmpty(exisingImportsOrExports)) { + if (ts.isEmpty(existingImportsOrExports)) { return exportsOfModule; } - return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(exisingImportsOrExports, e.name); }); + return ts.filter(exportsOfModule, function (e) { return !ts.lookUp(existingImportsOrExports, e.name); }); } /** * Filters out completion suggestions for named imports or exports. @@ -48335,10 +49751,10 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 248 /* PropertyAssignment */ && - m.kind !== 249 /* ShorthandPropertyAssignment */ && - m.kind !== 166 /* BindingElement */ && - m.kind !== 144 /* MethodDeclaration */) { + if (m.kind !== 249 /* PropertyAssignment */ && + m.kind !== 250 /* ShorthandPropertyAssignment */ && + m.kind !== 167 /* BindingElement */ && + m.kind !== 145 /* MethodDeclaration */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -48346,7 +49762,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 166 /* BindingElement */ && m.propertyName) { + if (m.kind === 167 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 69 /* Identifier */) { existingName = m.propertyName.text; @@ -48376,7 +49792,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 241 /* JsxAttribute */) { + if (attr.kind === 242 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -48389,21 +49805,21 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; 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() }; } var sourceFile = getValidSourceFile(fileName); var entries = []; - if (isRightOfDot && ts.isSourceFileJavaScript(sourceFile)) { + if (ts.isSourceFileJavaScript(sourceFile)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 240 /* JsxClosingElement */) { + location.parent && location.parent.kind === 241 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -48427,11 +49843,15 @@ var ts; ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, uniqueNames) { + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var target = program.getCompilerOptions().target; var nameTable = getNameTable(sourceFile); for (var name_35 in nameTable) { + // Skip identifiers produced only from the current location + if (nameTable[name_35] === position) { + continue; + } if (!uniqueNames[name_35]) { uniqueNames[name_35] = name_35; var displayName = getCompletionEntryDisplayName(name_35, target, /*performCharacterChecks*/ true); @@ -48484,8 +49904,8 @@ var ts; var start = new Date().getTime(); var uniqueNames = {}; if (symbols) { - for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { - var symbol = symbols_3[_i]; + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); @@ -48507,11 +49927,11 @@ var ts; if (completionData) { var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. - var target = program.getCompilerOptions().target; + var target_2 = 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 // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks*/ false, location_2) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target_2, /*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 { @@ -48540,7 +49960,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 189 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 190 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -48639,10 +50059,10 @@ var ts; if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { symbolKind = ScriptElementKind.memberVariableElement; } - var signature; + var signature = void 0; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 169 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 170 /* 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)) { @@ -48650,8 +50070,8 @@ var ts; } } // try get the call/construct signature from the type if it matches - var callExpression; - if (location.kind === 171 /* CallExpression */ || location.kind === 172 /* NewExpression */) { + var callExpression = void 0; + if (location.kind === 172 /* CallExpression */ || location.kind === 173 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -48664,7 +50084,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 172 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 173 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -48717,24 +50137,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 145 /* Constructor */)) { + (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 146 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 145 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 146 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 145 /* Constructor */) { + if (functionDeclaration.kind === 146 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 148 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 149 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -48743,7 +50163,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 189 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 190 /* 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 @@ -48766,7 +50186,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(133 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -48787,7 +50207,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 221 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 222 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -48810,17 +50230,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 138 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 139 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 149 /* ConstructSignature */) { + if (declaration.kind === 150 /* ConstructSignature */) { displayParts.push(ts.keywordPart(92 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 148 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 149 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -48829,7 +50249,7 @@ var ts; // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(132 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(133 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -48840,7 +50260,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 250 /* EnumMember */) { + if (declaration.kind === 251 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -48856,13 +50276,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 224 /* ImportEqualsDeclaration */) { + if (declaration.kind === 225 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(56 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(128 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); @@ -48989,10 +50409,10 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 69 /* Identifier */: - case 169 /* PropertyAccessExpression */: - case 136 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: + case 137 /* QualifiedName */: case 97 /* ThisKeyword */: - case 162 /* ThisType */: + case 163 /* ThisType */: case 95 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -49071,8 +50491,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 145 /* Constructor */) || - (!selectConstructors && (d.kind === 216 /* FunctionDeclaration */ || d.kind === 144 /* MethodDeclaration */ || d.kind === 143 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 146 /* Constructor */) || + (!selectConstructors && (d.kind === 217 /* FunctionDeclaration */ || d.kind === 145 /* MethodDeclaration */ || d.kind === 144 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -49132,7 +50552,14 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 69 /* Identifier */ && node.parent === declaration) { + // Go to the original declaration for cases: + // + // (1) when the aliased symbol was declared in the location(parent). + // (2) when the aliased symbol is originating from a named import. + // + if (node.kind === 69 /* Identifier */ && + (node.parent === declaration || + (declaration.kind === 230 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 229 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -49141,16 +50568,16 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 249 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 250 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; } var shorthandDeclarations = shorthandSymbol.getDeclarations(); - var shorthandSymbolKind = getSymbolKind(shorthandSymbol, node); - var shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol); - var shorthandContainerName = typeChecker.symbolToString(symbol.parent, node); - return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName); }); + var shorthandSymbolKind_1 = getSymbolKind(shorthandSymbol, node); + var shorthandSymbolName_1 = typeChecker.symbolToString(shorthandSymbol); + var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); } return getDefinitionFromSymbol(symbol, node); } @@ -49172,13 +50599,13 @@ var ts; return undefined; } if (type.flags & 16384 /* Union */) { - var result = []; + var result_3 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(/*to*/ result_3, /*from*/ getDefinitionFromSymbol(t.symbol, node)); } }); - return result; + return result_3; } if (!type.symbol) { return undefined; @@ -49188,10 +50615,10 @@ var ts; function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { - var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); + var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); // 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; }); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); } return results; } @@ -49217,7 +50644,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 69 /* Identifier */ || node.kind === 97 /* ThisKeyword */ || - node.kind === 162 /* ThisType */ || + node.kind === 163 /* ThisType */ || node.kind === 95 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { @@ -49271,75 +50698,75 @@ var ts; switch (node.kind) { case 88 /* IfKeyword */: case 80 /* ElseKeyword */: - if (hasKind(node.parent, 199 /* IfStatement */)) { + if (hasKind(node.parent, 200 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 207 /* ReturnStatement */)) { + if (hasKind(node.parent, 208 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 211 /* ThrowStatement */)) { + if (hasKind(node.parent, 212 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 212 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 213 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 100 /* TryKeyword */: case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 212 /* TryStatement */)) { + if (hasKind(parent(node), 213 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 209 /* SwitchStatement */)) { + if (hasKind(node.parent, 210 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 71 /* CaseKeyword */: case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 209 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 210 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 70 /* BreakKeyword */: case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 206 /* BreakStatement */) || hasKind(node.parent, 205 /* ContinueStatement */)) { + if (hasKind(node.parent, 207 /* BreakStatement */) || hasKind(node.parent, 206 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 86 /* ForKeyword */: - if (hasKind(node.parent, 202 /* ForStatement */) || - hasKind(node.parent, 203 /* ForInStatement */) || - hasKind(node.parent, 204 /* ForOfStatement */)) { + if (hasKind(node.parent, 203 /* ForStatement */) || + hasKind(node.parent, 204 /* ForInStatement */) || + hasKind(node.parent, 205 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 104 /* WhileKeyword */: case 79 /* DoKeyword */: - if (hasKind(node.parent, 201 /* WhileStatement */) || hasKind(node.parent, 200 /* DoStatement */)) { + if (hasKind(node.parent, 202 /* WhileStatement */) || hasKind(node.parent, 201 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 145 /* Constructor */)) { + if (hasKind(node.parent, 146 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 123 /* GetKeyword */: - case 129 /* SetKeyword */: - if (hasKind(node.parent, 146 /* GetAccessor */) || hasKind(node.parent, 147 /* SetAccessor */)) { + case 130 /* SetKeyword */: + if (hasKind(node.parent, 147 /* GetAccessor */) || hasKind(node.parent, 148 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 196 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 197 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -49355,10 +50782,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 /* ThrowStatement */) { + if (node.kind === 212 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 212 /* TryStatement */) { + else if (node.kind === 213 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -49385,19 +50812,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 === 251 /* SourceFile */) { - return parent_13; + var parent_14 = child.parent; + if (ts.isFunctionBlock(parent_14) || parent_14.kind === 252 /* SourceFile */) { + return parent_14; } // 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 === 212 /* TryStatement */) { - var tryStatement = parent_13; + if (parent_14.kind === 213 /* TryStatement */) { + var tryStatement = parent_14; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_14; } return undefined; } @@ -49406,7 +50833,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 206 /* BreakStatement */ || node.kind === 205 /* ContinueStatement */) { + if (node.kind === 207 /* BreakStatement */ || node.kind === 206 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -49421,16 +50848,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 209 /* SwitchStatement */: - if (statement.kind === 205 /* ContinueStatement */) { + case 210 /* SwitchStatement */: + if (statement.kind === 206 /* ContinueStatement */) { continue; } // Fall through. - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 201 /* WhileStatement */: - case 200 /* DoStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 202 /* WhileStatement */: + case 201 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -49449,24 +50876,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 === 217 /* ClassDeclaration */ || - container.kind === 189 /* ClassExpression */ || - (declaration.kind === 139 /* Parameter */ && hasKind(container, 145 /* Constructor */)))) { + if (!(container.kind === 218 /* ClassDeclaration */ || + container.kind === 190 /* ClassExpression */ || + (declaration.kind === 140 /* Parameter */ && hasKind(container, 146 /* Constructor */)))) { return undefined; } } else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 217 /* ClassDeclaration */ || container.kind === 189 /* ClassExpression */)) { + if (!(container.kind === 218 /* ClassDeclaration */ || container.kind === 190 /* ClassExpression */)) { return undefined; } } else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 222 /* ModuleBlock */ || container.kind === 251 /* SourceFile */)) { + if (!(container.kind === 223 /* ModuleBlock */ || container.kind === 252 /* SourceFile */)) { return undefined; } } else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 217 /* ClassDeclaration */ || declaration.kind === 217 /* ClassDeclaration */)) { + if (!(container.kind === 218 /* ClassDeclaration */ || declaration.kind === 218 /* ClassDeclaration */)) { return undefined; } } @@ -49478,8 +50905,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 222 /* ModuleBlock */: - case 251 /* SourceFile */: + case 223 /* ModuleBlock */: + case 252 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -49488,17 +50915,17 @@ var ts; nodes = container.statements; } break; - case 145 /* Constructor */: + case 146 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 217 /* ClassDeclaration */: - case 189 /* ClassExpression */: + case 218 /* ClassDeclaration */: + case 190 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 56 /* AccessibilityModifier */) { + if (modifierFlag & 28 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 145 /* Constructor */ && member; + return member.kind === 146 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -49520,17 +50947,17 @@ var ts; function getFlagFromModifier(modifier) { switch (modifier) { case 112 /* PublicKeyword */: - return 8 /* Public */; + return 4 /* Public */; case 110 /* PrivateKeyword */: - return 16 /* Private */; + return 8 /* Private */; case 111 /* ProtectedKeyword */: - return 32 /* Protected */; + return 16 /* Protected */; case 113 /* StaticKeyword */: - return 64 /* Static */; + return 32 /* Static */; case 82 /* ExportKeyword */: - return 2 /* Export */; + return 1 /* Export */; case 122 /* DeclareKeyword */: - return 4 /* Ambient */; + return 2 /* Ambient */; case 115 /* AbstractKeyword */: return 128 /* Abstract */; default: @@ -49551,13 +50978,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 146 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 147 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 147 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 148 /* 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, 123 /* GetKeyword */, 129 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 130 /* SetKeyword */); }); } } } @@ -49575,7 +51002,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 200 /* DoStatement */) { + if (loopNode.kind === 201 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { @@ -49596,13 +51023,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 202 /* ForStatement */: - case 203 /* ForInStatement */: - case 204 /* ForOfStatement */: - case 200 /* DoStatement */: - case 201 /* WhileStatement */: + case 203 /* ForStatement */: + case 204 /* ForInStatement */: + case 205 /* ForOfStatement */: + case 201 /* DoStatement */: + case 202 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -49656,7 +51083,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 195 /* Block */))) { + if (!(func && hasKind(func.body, 196 /* Block */))) { return undefined; } var keywords = []; @@ -49672,7 +51099,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 199 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 200 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -49685,7 +51112,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 199 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 200 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -49802,7 +51229,7 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 97 /* ThisKeyword */ || node.kind === 162 /* ThisType */) { + if (node.kind === 97 /* ThisKeyword */ || node.kind === 163 /* ThisType */) { return getReferencesForThisKeyword(node, sourceFiles); } if (node.kind === 95 /* SuperKeyword */) { @@ -49840,7 +51267,7 @@ var ts; var sourceFile = sourceFiles_3[_i]; cancellationToken.throwIfCancellationRequested(); var nameTable = getNameTable(sourceFile); - if (ts.lookUp(nameTable, internedName)) { + if (ts.lookUp(nameTable, internedName) !== undefined) { result = result || []; getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } @@ -49864,7 +51291,7 @@ var ts; }; } function isImportSpecifierSymbol(symbol) { - return (symbol.flags & 8388608 /* Alias */) && !!ts.getDeclarationOfKind(symbol, 229 /* ImportSpecifier */); + return (symbol.flags & 8388608 /* Alias */) && !!ts.getDeclarationOfKind(symbol, 230 /* ImportSpecifier */); } function getInternedName(symbol, location, declarations) { // If this is an export or import specifier it could have been renamed using the 'as' syntax. @@ -49890,18 +51317,18 @@ 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 === 176 /* FunctionExpression */ || valueDeclaration.kind === 189 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 177 /* FunctionExpression */ || valueDeclaration.kind === 190 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16 /* Private */) ? d : undefined; }); + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 217 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 218 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visibile outside its declaration scope. + // So consider it visible outside its declaration scope. if (symbol.flags & 8388608 /* Alias */) { return undefined; } @@ -49913,8 +51340,8 @@ var ts; var scope; var declarations = symbol.getDeclarations(); if (declarations) { - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; @@ -49923,7 +51350,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 251 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 252 /* 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; @@ -50022,7 +51449,7 @@ var ts; var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, container.getStart(), container.getEnd()); if (possiblePositions.length) { // Build the set of symbols to search for, initially it has only the current symbol - var searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation); + var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); @@ -50054,12 +51481,12 @@ var ts; if (referenceSymbol) { var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); + var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation); if (relatedSymbol) { var referencedSymbol = getReferencedSymbol(relatedSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation)); } - else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { + else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { var referencedSymbol = getReferencedSymbol(shorthandValueSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } @@ -50094,15 +51521,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 64 /* Static */; + var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -50122,7 +51549,7 @@ var ts; // 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. - if (container && (64 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + if (container && (32 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { references.push(getReferenceEntryFromNode(node)); } }); @@ -50132,29 +51559,29 @@ var ts; function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 64 /* Static */; + var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 251 /* SourceFile */: + case 252 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 177 /* 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. @@ -50163,7 +51590,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 251 /* SourceFile */) { + if (searchSpaceNode.kind === 252 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -50189,33 +51616,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 162 /* ThisType */)) { + if (!node || (node.kind !== 97 /* ThisKeyword */ && node.kind !== 163 /* ThisType */)) { return; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 189 /* ClassExpression */: - case 217 /* ClassDeclaration */: + case 190 /* ClassExpression */: + case 218 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64 /* Static */) === staticFlag) { + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 32 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 251 /* SourceFile */: - if (container.kind === 251 /* SourceFile */ && !ts.isExternalModule(container)) { + case 252 /* SourceFile */: + if (container.kind === 252 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -50226,16 +51653,16 @@ var ts; function populateSearchSymbolSet(symbol, location) { // The search set contains at least the current symbol var result = [symbol]; - // If the symbol is an alias, add what it alaises to the list + // If the symbol is an alias, add what it aliases to the list if (isImportSpecifierSymbol(symbol)) { result.push(typeChecker.getAliasedSymbol(symbol)); } - // For export specifiers, the exported name can be refering to a local symbol, e.g.: + // For export specifiers, the exported name can be referring to a local symbol, e.g.: // import {a} from "mod"; // export {a as somethingElse} // We want the *local* declaration of 'a' as declared in the import, // *not* as declared within "mod" (or farther) - if (location.parent.kind === 233 /* ExportSpecifier */) { + if (location.parent.kind === 234 /* ExportSpecifier */) { result.push(typeChecker.getExportSpecifierLocalTargetSymbol(location.parent)); } // If the location is in a context sensitive location (i.e. in an object literal) try @@ -50263,9 +51690,9 @@ var ts; } // If the symbol.valueDeclaration is a property parameter declaration, // we should include both parameter declaration symbol and property declaration symbol - // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in contructor.locals. + // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 139 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 140 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -50285,9 +51712,9 @@ var ts; /** * Find symbol of the given property-name and add the symbol to the given result array * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to serach for + * @param propertyName a name of property to search for * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisitng of the same symbol. + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. * The value of previousIterationSymbol is undefined when the function is first called. */ function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { @@ -50310,11 +51737,11 @@ var ts; } if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 217 /* ClassDeclaration */) { + if (declaration.kind === 218 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 218 /* InterfaceDeclaration */) { + else if (declaration.kind === 219 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -50351,7 +51778,7 @@ var ts; // import {a} from "mod"; // export {a as somethingElse} // We want the local target of the export (i.e. the import symbol) and not the final target (i.e. "mod".a) - if (referenceLocation.parent.kind === 233 /* ExportSpecifier */) { + if (referenceLocation.parent.kind === 234 /* ExportSpecifier */) { var aliasedSymbol = typeChecker.getExportSpecifierLocalTargetSymbol(referenceLocation.parent); if (searchSymbols.indexOf(aliasedSymbol) >= 0) { return aliasedSymbol; @@ -50375,9 +51802,9 @@ var ts; // 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 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3, /*previousIterationSymbolsCache*/ {}); - return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + var result_4 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, /*previousIterationSymbolsCache*/ {}); + return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } return undefined; }); @@ -50396,14 +51823,14 @@ var ts; return [unionProperty]; } else { - var result_4 = []; + var result_5 = []; ts.forEach(contextualType.types, function (t) { var symbol = t.getProperty(name_36); if (symbol) { - result_4.push(symbol); + result_5.push(symbol); } }); - return result_4; + return result_5; } } else { @@ -50425,7 +51852,7 @@ var ts; */ function getIntersectingMeaningFromDeclarations(meaning, declarations) { if (declarations) { - var lastIterationMeaning; + var lastIterationMeaning = void 0; do { // The result is order-sensitive, for instance if initialMeaning === Namespace, and declarations = [class, instantiated module] // we need to consider both as they initialMeaning intersects with the module in the namespace space, and the module @@ -50433,8 +51860,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; var declarationMeaning = getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -50465,10 +51892,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 183 /* PostfixUnaryExpression */ || parent.kind === 182 /* PrefixUnaryExpression */) { + if (parent.kind === 184 /* PostfixUnaryExpression */ || parent.kind === 183 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 184 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 185 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; } @@ -50499,33 +51926,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 139 /* Parameter */: - case 214 /* VariableDeclaration */: - case 166 /* BindingElement */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: - case 248 /* PropertyAssignment */: - case 249 /* ShorthandPropertyAssignment */: - case 250 /* EnumMember */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 145 /* Constructor */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 216 /* FunctionDeclaration */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: - case 247 /* CatchClause */: + case 140 /* Parameter */: + case 215 /* VariableDeclaration */: + case 167 /* BindingElement */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: + case 249 /* PropertyAssignment */: + case 250 /* ShorthandPropertyAssignment */: + case 251 /* EnumMember */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 146 /* Constructor */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 217 /* FunctionDeclaration */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: + case 248 /* CatchClause */: return 1 /* Value */; - case 138 /* TypeParameter */: - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: - case 156 /* TypeLiteral */: + case 139 /* TypeParameter */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: + case 157 /* TypeLiteral */: return 2 /* Type */; - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -50535,15 +51962,15 @@ var ts; else { return 4 /* Namespace */; } - case 228 /* NamedImports */: - case 229 /* ImportSpecifier */: - case 224 /* ImportEqualsDeclaration */: - case 225 /* ImportDeclaration */: - case 230 /* ExportAssignment */: - case 231 /* ExportDeclaration */: + case 229 /* NamedImports */: + case 230 /* ImportSpecifier */: + case 225 /* ImportEqualsDeclaration */: + case 226 /* ImportDeclaration */: + case 231 /* ExportAssignment */: + case 232 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 251 /* SourceFile */: + case 252 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -50552,10 +51979,10 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 152 /* TypeReference */ || - (node.parent.kind === 191 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 153 /* TypeReference */ || + (node.parent.kind === 192 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 97 /* ThisKeyword */ && !ts.isExpression(node)) || - node.kind === 162 /* ThisType */; + node.kind === 163 /* ThisType */; } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -50563,32 +51990,32 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 169 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 169 /* PropertyAccessExpression */) { + if (root.parent.kind === 170 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 170 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 191 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 246 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 192 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 247 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 217 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 218 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + return (decl.kind === 218 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || + (decl.kind === 219 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 136 /* QualifiedName */) { - while (root.parent && root.parent.kind === 136 /* QualifiedName */) { + if (root.parent.kind === 137 /* QualifiedName */) { + while (root.parent && root.parent.kind === 137 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 152 /* TypeReference */ && !isLastClause; + return root.parent.kind === 153 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 136 /* QualifiedName */) { + while (node.parent.kind === 137 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -50598,15 +52025,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 136 /* QualifiedName */ && + if (node.parent.kind === 137 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 224 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 225 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 230 /* ExportAssignment */) { + if (node.parent.kind === 231 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -50646,16 +52073,16 @@ var ts; return; } switch (node.kind) { - case 169 /* PropertyAccessExpression */: - case 136 /* QualifiedName */: + case 170 /* PropertyAccessExpression */: + case 137 /* QualifiedName */: case 9 /* StringLiteral */: - case 163 /* StringLiteralType */: + case 164 /* StringLiteralType */: case 84 /* FalseKeyword */: case 99 /* TrueKeyword */: case 93 /* NullKeyword */: case 95 /* SuperKeyword */: case 97 /* ThisKeyword */: - case 162 /* ThisType */: + case 163 /* ThisType */: case 69 /* Identifier */: break; // Cant create the text span @@ -50672,7 +52099,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 221 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 222 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -50713,10 +52140,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 221 /* ModuleDeclaration */: - case 217 /* ClassDeclaration */: - case 218 /* InterfaceDeclaration */: - case 216 /* FunctionDeclaration */: + case 222 /* ModuleDeclaration */: + case 218 /* ClassDeclaration */: + case 219 /* InterfaceDeclaration */: + case 217 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -50770,7 +52197,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 221 /* ModuleDeclaration */ && + return declaration.kind === 222 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -50931,16 +52358,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 270 /* JSDocParameterTag */: + case 271 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 273 /* JSDocTemplateTag */: + case 274 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 272 /* JSDocTypeTag */: + case 273 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 271 /* JSDocReturnTag */: + case 272 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -50998,19 +52425,53 @@ var ts; pushClassification(start, end - start, type); } } - function classifyTokenOrJsxText(token) { - if (ts.nodeIsMissing(token)) { - return; + /** + * Returns true if node should be treated as classified and no further processing is required. + * False will mean that node is not classified and traverse routine should recurse into node contents. + */ + function tryClassifyNode(node) { + if (ts.nodeIsMissing(node)) { + return true; } - var tokenStart = token.kind === 239 /* JsxText */ ? token.pos : classifyLeadingTriviaAndGetTokenStart(token); - var tokenWidth = token.end - tokenStart; + var classifiedElementName = tryClassifyJsxElementName(node); + if (!ts.isToken(node) && node.kind !== 240 /* JsxText */ && classifiedElementName === undefined) { + return false; + } + var tokenStart = node.kind === 240 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { - var type = classifyTokenType(token.kind, token); + var type = classifiedElementName || classifyTokenType(node.kind, node); if (type) { pushClassification(tokenStart, tokenWidth, type); } } + return true; + } + function tryClassifyJsxElementName(token) { + switch (token.parent && token.parent.kind) { + case 239 /* JsxOpeningElement */: + if (token.parent.tagName === token) { + return 19 /* jsxOpenTagName */; + } + break; + case 241 /* JsxClosingElement */: + if (token.parent.tagName === token) { + return 20 /* jsxCloseTagName */; + } + break; + case 238 /* JsxSelfClosingElement */: + if (token.parent.tagName === token) { + return 21 /* jsxSelfClosingTagName */; + } + break; + case 242 /* JsxAttribute */: + if (token.parent.name === token) { + return 22 /* jsxAttribute */; + } + break; + } + return undefined; } // 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 @@ -51032,17 +52493,17 @@ var ts; if (token) { if (tokenKind === 56 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 214 /* VariableDeclaration */ || - token.parent.kind === 142 /* PropertyDeclaration */ || - token.parent.kind === 139 /* Parameter */ || - token.parent.kind === 241 /* JsxAttribute */) { + if (token.parent.kind === 215 /* VariableDeclaration */ || + token.parent.kind === 143 /* PropertyDeclaration */ || + token.parent.kind === 140 /* Parameter */ || + token.parent.kind === 242 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 184 /* BinaryExpression */ || - token.parent.kind === 182 /* PrefixUnaryExpression */ || - token.parent.kind === 183 /* PostfixUnaryExpression */ || - token.parent.kind === 185 /* ConditionalExpression */) { + if (token.parent.kind === 185 /* BinaryExpression */ || + token.parent.kind === 183 /* PrefixUnaryExpression */ || + token.parent.kind === 184 /* PostfixUnaryExpression */ || + token.parent.kind === 186 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -51051,8 +52512,8 @@ var ts; else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 9 /* StringLiteral */ || tokenKind === 163 /* StringLiteralType */) { - return token.parent.kind === 241 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 9 /* StringLiteral */ || tokenKind === 164 /* StringLiteralType */) { + return token.parent.kind === 242 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -51062,61 +52523,42 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 239 /* JsxText */) { + else if (tokenKind === 240 /* JsxText */) { return 23 /* jsxText */; } else if (tokenKind === 69 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 138 /* TypeParameter */: + case 139 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 218 /* InterfaceDeclaration */: + case 219 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 139 /* Parameter */: + case 140 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } return; - case 238 /* JsxOpeningElement */: - if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; - } - return; - case 240 /* JsxClosingElement */: - if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; - } - return; - case 237 /* JsxSelfClosingElement */: - if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; - } - return; - case 241 /* JsxAttribute */: - if (token.parent.name === token) { - return 22 /* jsxAttribute */; - } } } return 2 /* identifier */; @@ -51132,10 +52574,7 @@ var ts; var children = element.getChildren(sourceFile); for (var i = 0, n = children.length; i < n; i++) { var child = children[i]; - if (ts.isToken(child) || child.kind === 239 /* JsxText */) { - classifyTokenOrJsxText(child); - } - else { + if (!tryClassifyNode(child)) { // Recurse into our child nodes. processElement(child); } @@ -51259,19 +52698,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 145 /* Constructor */: - case 217 /* ClassDeclaration */: - case 196 /* VariableStatement */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 146 /* Constructor */: + case 218 /* ClassDeclaration */: + case 197 /* VariableStatement */: break findOwner; - case 251 /* SourceFile */: + case 252 /* SourceFile */: return undefined; - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 221 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 222 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -51284,8 +52723,7 @@ var ts; 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 newLine = ts.getNewLineOrDefaultFromHost(host); var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; @@ -51313,7 +52751,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 196 /* VariableStatement */) { + if (commentOwner.kind === 197 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -51331,17 +52769,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 175 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 176 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return rightHandSide.parameters; - case 189 /* ClassExpression */: + case 190 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 145 /* Constructor */) { + if (member.kind === 146 /* Constructor */) { return member.parameters; } } @@ -51363,7 +52801,7 @@ var ts; var result = []; if (descriptors.length > 0) { var regExp = getTodoCommentsRegExp(); - var matchArray; + var matchArray = void 0; while (matchArray = regExp.exec(fileContents)) { cancellationToken.throwIfCancellationRequested(); // If we got a match, here is what the match array will look like. Say the source text is: @@ -51434,11 +52872,11 @@ var ts; // comment portion. var singleLineCommentStart = /(?:\/\/+\s*)/.source; var multiLineCommentStart = /(?:\/\*+\s*)/.source; - var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; + var anyNumberOfSpacesAndAsterisksAtStartOfLine = /(?:^(?:\s|\*)*)/.source; // Match any of the above three TODO comment start regexps. // Note that the outermost group *is* a capture group. We want to capture the preamble // so that we can determine the starting position of the TODO comment match. - var preamble = "(" + anyNumberOfSpacesAndAsterixesAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + var preamble = "(" + anyNumberOfSpacesAndAsterisksAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; // Takes the descriptors and forms a regexp that matches them as if they were literals. // For example, if the descriptors are "TODO(jason)" and "HACK", then this will be: // @@ -51489,14 +52927,14 @@ var ts; var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); if (defaultLibFileName) { - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var current = declarations_10[_i]; - var sourceFile_2 = current.getSourceFile(); + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var current = declarations_11[_i]; + var sourceFile_3 = current.getSourceFile(); // TODO (drosen): When is there no source file? - if (!sourceFile_2) { + if (!sourceFile_3) { continue; } - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_3.fileName)); if (canonicalName === canonicalDefaultLibName) { return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); } @@ -51586,7 +53024,7 @@ var ts; function walk(node) { switch (node.kind) { case 69 /* Identifier */: - nameTable[node.text] = node.text; + nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -51595,9 +53033,9 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 235 /* ExternalModuleReference */ || + node.parent.kind === 236 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { - nameTable[node.text] = node.text; + nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; } break; default: @@ -51608,7 +53046,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 170 /* ElementAccessExpression */ && + node.parent.kind === 171 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -51656,7 +53094,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 123 /* GetKeyword */ || - keyword2 === 129 /* SetKeyword */ || + keyword2 === 130 /* SetKeyword */ || keyword2 === 121 /* ConstructorKeyword */ || keyword2 === 113 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -51815,10 +53253,10 @@ var ts; angleBracketStack--; } else if (token === 117 /* AnyKeyword */ || - token === 130 /* StringKeyword */ || - token === 128 /* NumberKeyword */ || + token === 131 /* StringKeyword */ || + token === 129 /* NumberKeyword */ || token === 120 /* BooleanKeyword */ || - token === 131 /* SymbolKeyword */) { + token === 132 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, @@ -51867,7 +53305,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 9 /* StringLiteral */ || token === 163 /* StringLiteralType */) { + if (token === 9 /* StringLiteral */ || token === 164 /* StringLiteralType */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -51990,7 +53428,7 @@ var ts; } } function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 135 /* LastKeyword */; + return token >= 70 /* FirstKeyword */ && token <= 136 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -52006,7 +53444,7 @@ var ts; case 8 /* NumericLiteral */: return 4 /* numericLiteral */; case 9 /* StringLiteral */: - case 163 /* StringLiteralType */: + case 164 /* StringLiteralType */: return 6 /* stringLiteral */; case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; @@ -52068,7 +53506,7 @@ var ts; */ function spanInSourceFileAtLocation(sourceFile, position) { // Cannot set breakpoint in dts file - if (sourceFile.flags & 4096 /* DeclarationFile */) { + if (sourceFile.isDeclarationFile) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -52118,113 +53556,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 196 /* VariableStatement */: + case 197 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 214 /* VariableDeclaration */: - case 142 /* PropertyDeclaration */: - case 141 /* PropertySignature */: + case 215 /* VariableDeclaration */: + case 143 /* PropertyDeclaration */: + case 142 /* PropertySignature */: return spanInVariableDeclaration(node); - case 139 /* Parameter */: + case 140 /* Parameter */: return spanInParameterDeclaration(node); - case 216 /* FunctionDeclaration */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 145 /* Constructor */: - case 176 /* FunctionExpression */: - case 177 /* ArrowFunction */: + case 217 /* FunctionDeclaration */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 146 /* Constructor */: + case 177 /* FunctionExpression */: + case 178 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 195 /* Block */: + case 196 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 222 /* ModuleBlock */: + case 223 /* ModuleBlock */: return spanInBlock(node); - case 247 /* CatchClause */: + case 248 /* CatchClause */: return spanInBlock(node.block); - case 198 /* ExpressionStatement */: + case 199 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 207 /* ReturnStatement */: + case 208 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 201 /* WhileStatement */: + case 202 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 200 /* DoStatement */: + case 201 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 213 /* DebuggerStatement */: + case 214 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 199 /* IfStatement */: + case 200 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 210 /* LabeledStatement */: + case 211 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 206 /* BreakStatement */: - case 205 /* ContinueStatement */: + case 207 /* BreakStatement */: + case 206 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 202 /* ForStatement */: + case 203 /* ForStatement */: return spanInForStatement(node); - case 203 /* ForInStatement */: + case 204 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 204 /* ForOfStatement */: + case 205 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 209 /* SwitchStatement */: + case 210 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* CaseClause */: - case 245 /* DefaultClause */: + case 245 /* CaseClause */: + case 246 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 212 /* TryStatement */: + case 213 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 211 /* ThrowStatement */: + case 212 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 230 /* ExportAssignment */: + case 231 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 224 /* ImportEqualsDeclaration */: + case 225 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 225 /* ImportDeclaration */: + case 226 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 231 /* ExportDeclaration */: + case 232 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 217 /* ClassDeclaration */: - case 220 /* EnumDeclaration */: - case 250 /* EnumMember */: - case 166 /* BindingElement */: + case 218 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 251 /* EnumMember */: + case 167 /* BindingElement */: // span on complete node return textSpan(node); - case 208 /* WithStatement */: + case 209 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 140 /* Decorator */: + case 141 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 164 /* ObjectBindingPattern */: - case 165 /* ArrayBindingPattern */: + case 165 /* ObjectBindingPattern */: + case 166 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 218 /* InterfaceDeclaration */: - case 219 /* TypeAliasDeclaration */: + case 219 /* InterfaceDeclaration */: + case 220 /* TypeAliasDeclaration */: return undefined; // Tokens: case 23 /* SemicolonToken */: @@ -52254,7 +53692,7 @@ var ts; case 72 /* CatchKeyword */: case 85 /* FinallyKeyword */: return spanInNextNode(node); - case 135 /* OfKeyword */: + case 136 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -52267,13 +53705,13 @@ var ts; // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern if ((node.kind === 69 /* Identifier */ || - node.kind == 188 /* SpreadElementExpression */ || - node.kind === 248 /* PropertyAssignment */ || - node.kind === 249 /* ShorthandPropertyAssignment */) && + node.kind == 189 /* SpreadElementExpression */ || + node.kind === 249 /* PropertyAssignment */ || + node.kind === 250 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 184 /* BinaryExpression */) { + if (node.kind === 185 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -52296,22 +53734,22 @@ var ts; } if (ts.isExpression(node)) { switch (node.parent.kind) { - case 200 /* DoStatement */: + case 201 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 140 /* Decorator */: + case 141 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 202 /* ForStatement */: - case 204 /* ForOfStatement */: + case 203 /* ForStatement */: + case 205 /* ForOfStatement */: return textSpan(node); - case 184 /* BinaryExpression */: + case 185 /* BinaryExpression */: if (node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 177 /* ArrowFunction */: + case 178 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -52320,13 +53758,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 248 /* PropertyAssignment */ && + if (node.parent.kind === 249 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 174 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 175 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -52334,8 +53772,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 214 /* VariableDeclaration */ || - node.parent.kind === 139 /* Parameter */)) { + if ((node.parent.kind === 215 /* VariableDeclaration */ || + node.parent.kind === 140 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -52343,7 +53781,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 184 /* BinaryExpression */) { + if (node.parent.kind === 185 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -52369,7 +53807,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 203 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 204 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern set breakpoint in binding pattern @@ -52379,8 +53817,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if (variableDeclaration.initializer || - (variableDeclaration.flags & 2 /* Export */) || - variableDeclaration.parent.parent.kind === 204 /* ForOfStatement */) { + (variableDeclaration.flags & 1 /* Export */) || + variableDeclaration.parent.parent.kind === 205 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -52395,7 +53833,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */); + !!(parameter.flags & 4 /* Public */) || !!(parameter.flags & 8 /* Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -52419,8 +53857,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 2 /* Export */) || - (functionDeclaration.parent.kind === 217 /* ClassDeclaration */ && functionDeclaration.kind !== 145 /* Constructor */); + return !!(functionDeclaration.flags & 1 /* Export */) || + (functionDeclaration.parent.kind === 218 /* ClassDeclaration */ && functionDeclaration.kind !== 146 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -52443,25 +53881,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 221 /* ModuleDeclaration */: + case 222 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 201 /* WhileStatement */: - case 199 /* IfStatement */: - case 203 /* ForInStatement */: + case 202 /* WhileStatement */: + case 200 /* IfStatement */: + case 204 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 202 /* ForStatement */: - case 204 /* ForOfStatement */: + case 203 /* ForStatement */: + case 205 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStaement) { - if (forLikeStaement.initializer.kind === 215 /* VariableDeclarationList */) { + if (forLikeStaement.initializer.kind === 216 /* VariableDeclarationList */) { // declaration list, set breakpoint in first declaration var variableDeclarationList = forLikeStaement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -52486,23 +53924,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 191 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 166 /* BindingElement */) { + if (bindingPattern.parent.kind === 167 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 165 /* ArrayBindingPattern */ && node.kind !== 164 /* ObjectBindingPattern */); - var elements = node.kind === 167 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 166 /* ArrayBindingPattern */ && node.kind !== 165 /* ObjectBindingPattern */); + var elements = node.kind === 168 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 190 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 191 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -52510,18 +53948,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 184 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 185 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 220 /* EnumDeclaration */: + case 221 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 217 /* ClassDeclaration */: + case 218 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 223 /* CaseBlock */: + case 224 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -52529,24 +53967,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 222 /* ModuleBlock */: + case 223 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 220 /* EnumDeclaration */: - case 217 /* ClassDeclaration */: + case 221 /* EnumDeclaration */: + case 218 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 195 /* Block */: + case 196 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 247 /* CatchClause */: + case 248 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 223 /* CaseBlock */: + case 224 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -52554,7 +53992,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 164 /* ObjectBindingPattern */: + case 165 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -52570,7 +54008,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 165 /* ArrayBindingPattern */: + case 166 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -52585,12 +54023,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 200 /* DoStatement */ || - node.parent.kind === 171 /* CallExpression */ || - node.parent.kind === 172 /* NewExpression */) { + if (node.parent.kind === 201 /* DoStatement */ || + node.parent.kind === 172 /* CallExpression */ || + node.parent.kind === 173 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 175 /* ParenthesizedExpression */) { + if (node.parent.kind === 176 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -52599,21 +54037,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 176 /* FunctionExpression */: - case 216 /* FunctionDeclaration */: - case 177 /* ArrowFunction */: - case 144 /* MethodDeclaration */: - case 143 /* MethodSignature */: - case 146 /* GetAccessor */: - case 147 /* SetAccessor */: - case 145 /* Constructor */: - case 201 /* WhileStatement */: - case 200 /* DoStatement */: - case 202 /* ForStatement */: - case 204 /* ForOfStatement */: - case 171 /* CallExpression */: - case 172 /* NewExpression */: - case 175 /* ParenthesizedExpression */: + case 177 /* FunctionExpression */: + case 217 /* FunctionDeclaration */: + case 178 /* ArrowFunction */: + case 145 /* MethodDeclaration */: + case 144 /* MethodSignature */: + case 147 /* GetAccessor */: + case 148 /* SetAccessor */: + case 146 /* Constructor */: + case 202 /* WhileStatement */: + case 201 /* DoStatement */: + case 203 /* ForStatement */: + case 205 /* ForOfStatement */: + case 172 /* CallExpression */: + case 173 /* NewExpression */: + case 176 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -52623,20 +54061,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 248 /* PropertyAssignment */ || - node.parent.kind === 139 /* Parameter */) { + node.parent.kind === 249 /* PropertyAssignment */ || + node.parent.kind === 140 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 174 /* TypeAssertionExpression */) { + if (node.parent.kind === 175 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 200 /* DoStatement */) { + if (node.parent.kind === 201 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -52644,7 +54082,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 204 /* ForOfStatement */) { + if (node.parent.kind === 205 /* ForOfStatement */) { // set using next token return spanInNextNode(node); } @@ -52773,6 +54211,14 @@ var ts; var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0 /* Unknown */; + } + }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { return this.shimHost.getScriptVersion(fileName); }; @@ -53239,7 +54685,8 @@ var ts; errors: [realizeDiagnostic(result.error, "\r\n")] }; } - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); return { options: configFile.options, files: configFile.fileNames, @@ -53334,5 +54781,5 @@ var TypeScript; // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "1.8"; +var toolsVersion = "1.9"; /* tslint:enable:no-unused-variable */